Browse Source

Add RuntimeResult demo

pull/988/head
Hsu Still 7 years ago
parent
commit
7bbb21bff1
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
2 changed files with 17 additions and 0 deletions
  1. +4
    -0
      docs/guides/commands/post-execution.md
  2. +13
    -0
      docs/guides/commands/samples/command_executed_adv_demo.cs

+ 4
- 0
docs/guides/commands/post-execution.md View File

@@ -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


+ 13
- 0
docs/guides/commands/samples/command_executed_adv_demo.cs View File

@@ -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;
}
}

Loading…
Cancel
Save