diff --git a/docs/guides/commands/post-execution.md b/docs/guides/commands/post-execution.md index 28f63659b..71f1801b3 100644 --- a/docs/guides/commands/post-execution.md +++ b/docs/guides/commands/post-execution.md @@ -37,11 +37,10 @@ about the impact in the [FAQ](xref:FAQ.Commands.General). Enter [CommandExecuted], an event that was introduced in Discord.Net 2.0. This event is raised whenever a command is -successfully executed **without any run-time exceptions** or **any -parsing or precondition failure**. This means this event can be -used to streamline your post-execution design, and the best thing -about this event is that it is not prone to `RunMode.Async`'s -[ExecuteAsync] drawbacks. +executed, regardless of its execution status. This means this +event can be used to streamline your post-execution design, and the +best thing about this event is that it is not prone +to `RunMode.Async`'s [ExecuteAsync] drawbacks. Thus, we can begin working on code such as: diff --git a/docs/guides/commands/samples/post-execution/command_executed_adv_demo.cs b/docs/guides/commands/samples/post-execution/command_executed_adv_demo.cs index 1ce40c51d..dbd75f040 100644 --- a/docs/guides/commands/samples/post-execution/command_executed_adv_demo.cs +++ b/docs/guides/commands/samples/post-execution/command_executed_adv_demo.cs @@ -1,4 +1,4 @@ -public async Task OnCommandExecutedAsync(CommandInfo command, ICommandContext context, IResult result) +public async Task OnCommandExecutedAsync(Optional command, ICommandContext context, IResult result) { switch(result) { diff --git a/docs/guides/commands/samples/post-execution/command_executed_demo.cs b/docs/guides/commands/samples/post-execution/command_executed_demo.cs index b87f4ef06..87ab40b5b 100644 --- a/docs/guides/commands/samples/post-execution/command_executed_demo.cs +++ b/docs/guides/commands/samples/post-execution/command_executed_demo.cs @@ -6,7 +6,7 @@ public async Task SetupAsync() // Hook the command handler _client.MessageReceived += HandleCommandAsync; } -public async Task OnCommandExecutedAsync(CommandInfo command, ICommandContext context, IResult result) +public async Task OnCommandExecutedAsync(Optional command, ICommandContext context, IResult result) { // We have access to the information of the command executed, // the context of the command, and the result returned from the @@ -20,7 +20,8 @@ public async Task OnCommandExecutedAsync(CommandInfo command, ICommandContext co // ...or even log the result (the method used should fit into // your existing log handler) - await _log.LogAsync(new LogMessage(LogSeverity.Info, "CommandExecution", $"{command?.Name} was executed at {DateTime.UtcNow}.")); + var commandName = command.HasValue ? command.Name : "A command"; + await _log.LogAsync(new LogMessage(LogSeverity.Info, "CommandExecution", $"{commandName} was executed at {DateTime.UtcNow}.")); } public async Task HandleCommandAsync(SocketMessage msg) {