From fb8dbcae4beef1684f22cf7d4c3cc3be0918d958 Mon Sep 17 00:00:00 2001 From: Rithari Date: Sat, 20 Oct 2018 15:59:06 +0200 Subject: [PATCH] Added check to ignore bot commands. (#1175) Added the usual check to ignore bot commands in this sample CommandHandler as seen and approved in #1174. --- .../commands/samples/post-execution/command_executed_demo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8d8fb911b..b87f4ef06 100644 --- a/docs/guides/commands/samples/post-execution/command_executed_demo.cs +++ b/docs/guides/commands/samples/post-execution/command_executed_demo.cs @@ -27,7 +27,7 @@ public async Task HandleCommandAsync(SocketMessage msg) var message = messageParam as SocketUserMessage; if (message == null) return; int argPos = 0; - if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos))) return; + if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos)) || message.Author.IsBot) return; var context = new SocketCommandContext(_client, message); var result = await _commands.ExecuteAsync(context, argPos, _services); // Optionally, you may pass the result manually into your @@ -35,4 +35,4 @@ public async Task HandleCommandAsync(SocketMessage msg) // precondition failures in the same method. // await OnCommandExecutedAsync(null, context, result); -} \ No newline at end of file +}