+ Starting from this commit, there will be overwrite files added to provide further details about certain APIs.pull/988/head
@@ -0,0 +1,27 @@ | |||||
--- | |||||
uid: Discord.Commands.CommandException | |||||
--- | |||||
### Remarks | |||||
This @System.Exception class is typically used when diagnosing | |||||
an error thrown during the execution of a command. You will find the | |||||
thrown exception passed into | |||||
[LogMessage.Exception](xref:Discord.LogMessage.Exception), which is | |||||
sent to your [CommandService.Log](xref:Discord.Commands.CommandService.Log) | |||||
event handler. | |||||
You may use this information to handle runtime exceptions after | |||||
execution. Below is an example of how you may use this: | |||||
```cs | |||||
public Task LogHandlerAsync(LogMessage logMessage) | |||||
{ | |||||
// Note that this casting method requires C#7 and up. | |||||
if (logMessage?.Exception is CommandException cmdEx) | |||||
{ | |||||
Console.WriteLine($"{cmdEx.GetBaseException().GetType()} was thrown while executing {cmdEx.Command.Aliases.First()} in {cmdEx.Context.Channel} by {cmdEx.Context.User}."); | |||||
} | |||||
return Task.CompletedTask; | |||||
} | |||||
``` |
@@ -0,0 +1,20 @@ | |||||
--- | |||||
uid: Discord.Commands.DontAutoLoadAttribute | |||||
--- | |||||
### Remarks | |||||
The attribute can be applied to a public class that inherits | |||||
@Discord.Commands.ModuleBase. By applying this attribute, | |||||
@Discord.Commands.CommandService.AddModulesAsync* will not discover and | |||||
add the marked module to the CommandService. | |||||
### Example | |||||
```cs | |||||
[DontAutoLoad] | |||||
public class MyModule : ModuleBase<SocketCommandContext> | |||||
{ | |||||
// ... | |||||
} | |||||
``` |
@@ -0,0 +1,26 @@ | |||||
--- | |||||
uid: Discord.Commands.DontInjectAttribute | |||||
--- | |||||
### Remarks | |||||
The attribute can be applied to a public settable property inside a | |||||
@Discord.Commands.ModuleBase based class. By applying this property, | |||||
the marked property will not be automatically injected of the | |||||
dependency. See [Dependency Injection](../../guides/commands/commands.md#dependency-injection) | |||||
to learn more. | |||||
### Example | |||||
```cs | |||||
public class MyModule : ModuleBase<SocketCommandContext> | |||||
{ | |||||
[DontInject] | |||||
public MyService MyService { get; set; } | |||||
public MyModule() | |||||
{ | |||||
MyService = new MyService(); | |||||
} | |||||
} | |||||
``` |
@@ -0,0 +1,10 @@ | |||||
--- | |||||
uid: Discord.Commands.ShardedCommandContext | |||||
--- | |||||
### Example | |||||
An example of how this class is used the command system can be seen | |||||
below: | |||||
[!code[Sample module](../../guides/commands/samples/empty-module.cs)] | |||||
[!code[Command handler](../../guides/commands/samples/command_handler.cs)] |
@@ -0,0 +1,28 @@ | |||||
--- | |||||
uid: Discord.EmbedBuilder | |||||
--- | |||||
### Remarks | |||||
This builder class is used to build an @Discord.Embed (rich embed) | |||||
object that will be ready to be sent via @Discord.IMessageChannel.SendMessageAsync* | |||||
after @Discord.EmbedBuilder.Build* is called. | |||||
### Example | |||||
```cs | |||||
public async Task SendRichEmbedAsync() | |||||
{ | |||||
var embed = new EmbedBuilder | |||||
{ | |||||
// Embed property can be set within object initializer | |||||
Title = "Hello world!" | |||||
} | |||||
// Or with the method | |||||
.WithTitle("I overwrote the title.") | |||||
.WithDescription("I am a description.") | |||||
.WithUrl("https://example.com") | |||||
.Build(); | |||||
await _channel.SendMessageAsync(string.Empty, embed: embed); | |||||
} | |||||
``` |