From 0925bd46c23eff98194516b12f36aa69a6176009 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 20 Jun 2016 03:22:31 +0200 Subject: [PATCH] ;acr can now take "all" as a role name (you can now ban all commands from a module for all roles) Very useful when making DJ role :+1: --- .../Modules/Permissions/PermissionsModule.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Modules/Permissions/PermissionsModule.cs b/NadekoBot/Modules/Permissions/PermissionsModule.cs index 9b7012c1..4a0c4b30 100644 --- a/NadekoBot/Modules/Permissions/PermissionsModule.cs +++ b/NadekoBot/Modules/Permissions/PermissionsModule.cs @@ -637,7 +637,7 @@ namespace NadekoBot.Modules.Permissions cgb.CreateCommand(Prefix + "allrolecmds").Alias(Prefix + "arc") .Parameter("module", ParameterType.Required) .Parameter("bool", ParameterType.Required) - .Parameter("channel", ParameterType.Unparsed) + .Parameter("role", ParameterType.Unparsed) .Description("Sets permissions for all commands from a certain module at the role level.\n**Usage**: ;arc [module_name] [enable/disable] [role_name]") .Do(async e => { @@ -645,12 +645,27 @@ namespace NadekoBot.Modules.Permissions { var state = PermissionHelper.ValidateBool(e.GetArg("bool")); var module = PermissionHelper.ValidateModule(e.GetArg("module")); - var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("channel")); - foreach (var command in NadekoBot.Client.GetService().AllCommands.Where(c => c.Category == module)) + if (e.GetArg("role")?.ToLower() == "all") { - PermissionsHandler.SetRoleCommandPermission(role, command.Text, state); + foreach (var role in e.Server.Roles) + { + foreach (var command in NadekoBot.Client.GetService().AllCommands.Where(c => c.Category == module)) + { + PermissionsHandler.SetRoleCommandPermission(role, command.Text, state); + } + } + await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **all roles** role.").ConfigureAwait(false); + } + else + { + var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role")); + + foreach (var command in NadekoBot.Client.GetService().AllCommands.Where(c => c.Category == module)) + { + PermissionsHandler.SetRoleCommandPermission(role, command.Text, state); + } + await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } - await e.Channel.SendMessage($"All commands from the **{module}** module have been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false); } catch (ArgumentException exArg) {