From f3b9f358994b4f6ec3b8c78cd6f1eddaf79888fe Mon Sep 17 00:00:00 2001 From: Rithari Date: Fri, 12 Oct 2018 22:19:03 +0200 Subject: [PATCH] Add check for bot messages. Added a check so bot messages do not trigger any commands involuntariy. --- docs/guides/commands/samples/intro/command_handler.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/guides/commands/samples/intro/command_handler.cs b/docs/guides/commands/samples/intro/command_handler.cs index e4531fa41..efb31f9b9 100644 --- a/docs/guides/commands/samples/intro/command_handler.cs +++ b/docs/guides/commands/samples/intro/command_handler.cs @@ -35,9 +35,10 @@ public class CommandHandler // Create a number to track where the prefix ends and the command begins int argPos = 0; - // Determine if the message is a command based on the prefix + // Determine if the message is a command based on the prefix and make sure no bots trigger commands if (!(message.HasCharPrefix('!', ref argPos) || - message.HasMentionPrefix(_client.CurrentUser, ref argPos))) + message.HasMentionPrefix(_client.CurrentUser, ref argPos)) || + message.Author.IsBot) return; // Create a WebSocket-based command context based on the message @@ -60,4 +61,4 @@ public class CommandHandler // if (!result.IsSuccess) // await context.Channel.SendMessageAsync(result.ErrorReason); } -} \ No newline at end of file +}