public async Task ModHelpAsync([Remainder] string inputCommand = null) { if (!string.IsNullOrEmpty(inputCommand)) { await UserHelpHandler.DisplayCommandHelpMenu(Context, "elevated " + inputCommand); } else { await UserHelpHandler.DisplayModerationHelpMenu(Context); } }
//Command Handler public async Task HandleCommandAsync(SocketMessage messageParam) { // Don't process the command if it was a system message, if sender is bot SocketUserMessage message = messageParam as SocketUserMessage; if (message == null) { return; } if (message.Author.IsBot) { return; } //integer to determine when commands start int argPos = 0; //Ignore commands that are not using the prefix var context = new SocketCommandContext(_client, message); string commandPrefix = CommandGuildPrefixManager.GetGuildCommandPrefix(context); if (!(message.HasStringPrefix(commandPrefix + " ", ref argPos) || message.Author.IsBot)) { return; } var result = await _commands.ExecuteAsync(context : context, argPos : argPos, services : _services); //COMMAND LOGGING // Inform the user if the command fails if (!result.IsSuccess) { var guild = _client.GetGuild(384492615745142784); var channel = guild.GetTextChannel(504375404547801138); if (result.Error == CommandError.UnknownCommand) { //Find similar commands var commandHelpDefinitionStorage = XmlManager.FromXmlFile <HelpMenuCommands>(CoreMethod.GetFileLocation(@"CommandHelpDescription.xml")); string similarItemsString = UserHelpHandler.FindSimilarCommands( commandHelpDefinitionStorage.CommandHelpEntry.Select(i => i.CommandName).ToList(), message.ToString().Substring(CommandGuildPrefixManager.GetGuildCommandPrefix(context).Length + 1)); //If no similar matches are found, send nothing if (string.IsNullOrEmpty(similarItemsString)) { await context.Channel.SendMessageAsync("Invalid command, use `.d help` for a list of commands"); } //If similar matches are found, send suggestions else { await context.Channel.SendMessageAsync($"Invalid command, use `.d help` for a list of commands. Did you mean: \n {similarItemsString}"); } } else if (result.Error == CommandError.BadArgCount) { await context.Channel.SendMessageAsync($"Invalid command usage, use `.d help <command>` for correct command usage"); } else if (result.Error != CommandError.UnmetPrecondition) { await channel.SendMessageAsync($"[ERROR] **{message.Author.ToString()}** `{message}` >| {result.ErrorReason}"); } } }