diff --git a/docs/guides/commands/post-execution.md b/docs/guides/commands/post-execution.md index 14701ad8a..77a166746 100644 --- a/docs/guides/commands/post-execution.md +++ b/docs/guides/commands/post-execution.md @@ -93,6 +93,10 @@ Here's an example of a command that utilizes such logic: [!code[Usage](samples/customresult_usage.cs)] +And now we can check for it in our [CommandExecuted] handler: + +[!code[Usage](samples/command_executed_adv_demo.cs)] + ## CommandService.Log Event We have so far covered the handling of various result types, but we diff --git a/docs/guides/commands/samples/command_executed_adv_demo.cs b/docs/guides/commands/samples/command_executed_adv_demo.cs new file mode 100644 index 000000000..1ce40c51d --- /dev/null +++ b/docs/guides/commands/samples/command_executed_adv_demo.cs @@ -0,0 +1,13 @@ +public async Task OnCommandExecutedAsync(CommandInfo command, ICommandContext context, IResult result) +{ + switch(result) + { + case MyCustomResult customResult: + // do something extra with it + break; + default: + if (!string.IsNullOrEmpty(result.ErrorReason)) + await context.Channel.SendMessageAsync(result.ErrorReason); + break; + } +} \ No newline at end of file