private async Task <bool> _executeCommand(SocketUserMessage message) { // If the message is just the bot's prefix, don't attempt to respond to it (this reduces "Unknown command" spam). if (message.Content == Config.Prefix) { return(false); } int pos = _getCommandArgumentsPosition(message); var context = new CommandContext(_discord_client, message); var result = await CommandService.ExecuteAsync(context, pos, ServiceProvider); if (result.IsSuccess) { return(true); } bool show_error_message = true; if (result.Error == CommandError.BadArgCount) { // Get the name of the command that the user attempted to use. System.Text.RegularExpressions.Match command_m = System.Text.RegularExpressions.Regex.Match(message.Content.Substring(pos), @"^[^\s]+", System.Text.RegularExpressions.RegexOptions.IgnoreCase); // If help documentation exists for this command, display it. CommandHelpInfo command_info = HelpUtils.GetCommandInfo(command_m.Value); if (!(command_info is null)) { EmbedBuilder embed = new EmbedBuilder(); embed.WithColor(Color.Red); embed.WithTitle(string.Format("Incorrect usage of \"{0}\" command", command_m.Value)); embed.WithDescription("❌ " + result.ErrorReason); embed.AddField("Example(s) of correct usage:", command_info.ExamplesToString(Config.Prefix)); await context.Channel.SendMessageAsync("", false, embed.Build()); show_error_message = false; } } if (show_error_message) { await BotUtils.ReplyAsync_Error(context, result.ErrorReason); } return(false); }