Browse Source

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.
tags/2.0
Rithari Christopher F 6 years ago
parent
commit
fb8dbcae4b
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      docs/guides/commands/samples/post-execution/command_executed_demo.cs

+ 2
- 2
docs/guides/commands/samples/post-execution/command_executed_demo.cs View File

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

Loading…
Cancel
Save