public async Task ToggleModule([Remainder] string name) { var cmdService = Program.GetCommands(); var module = cmdService.Modules.SingleOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); if (module == null) { await ReplyAsync($":x: There is no module called `{name}`"); return; } if (module.Name.Equals("Server") || module.Name.Equals("Basic")) { await ReplyAsync($":x: The **{module.Name}** module can't be disabled."); return; } if (await DisabledCommandHandler.AddNew(module.Name, Context.Guild.Id, DisabledCommandType.Module)) { await ReplyAsync($":star: Module **{module.Name}** disabled... Use the same command again to re-enable"); return; } else { await DisabledCommandHandler.Remove(module.Name, Context.Guild.Id, DisabledCommandType.Module); await ReplyAsync($":star: Module **{module.Name}** re-enabled."); return; } }
public async Task ToggleReactionImages([Remainder] string name = "") { if (await DisabledCommandHandler.AddNew(name, Context.Guild.Id, DisabledCommandType.Images)) { await ReplyAsync($":star: **Reaction images** disabled... Use the same command again to re-enable"); return; } else { await DisabledCommandHandler.Remove(name, Context.Guild.Id, DisabledCommandType.Images); await ReplyAsync($":star: **Reaction images** re-enabled."); return; } }
public async Task ToggleCommand([Remainder] string name) { var cmdService = Program.GetCommands(); var command = cmdService.Commands.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); if (command == null) { await ReplyAsync($":x: There is no command called `{name}`"); return; } if (command.Name.Equals("ToggleModule") || command.Name.Equals("ToggleCommand") || command.Name.Equals("ToggleReactionImages") || command.Name.Equals("ListDisabledCommands")) { await ReplyAsync($":x: The **{command.Name}** command can't be disabled."); return; } if (await DisabledCommandHandler.AddNew(command.Name, Context.Guild.Id, DisabledCommandType.Command)) { await ReplyAsync($":star: Command **{command.Name}** disabled... Use the same command again to re-enable"); return; } else { await DisabledCommandHandler.Remove(command.Name, Context.Guild.Id, DisabledCommandType.Command); await ReplyAsync($":star: Command **{command.Name}** re-enabled."); return; } }