;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 👍
This commit is contained in:
parent
a6cbc706be
commit
0925bd46c2
@ -637,7 +637,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
cgb.CreateCommand(Prefix + "allrolecmds").Alias(Prefix + "arc")
|
cgb.CreateCommand(Prefix + "allrolecmds").Alias(Prefix + "arc")
|
||||||
.Parameter("module", ParameterType.Required)
|
.Parameter("module", ParameterType.Required)
|
||||||
.Parameter("bool", 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]")
|
.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 =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
@ -645,13 +645,28 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("channel"));
|
if (e.GetArg("role")?.ToLower() == "all")
|
||||||
|
{
|
||||||
|
foreach (var role in e.Server.Roles)
|
||||||
|
{
|
||||||
|
foreach (var command in NadekoBot.Client.GetService<CommandService>().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<CommandService>().AllCommands.Where(c => c.Category == module))
|
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
||||||
{
|
{
|
||||||
PermissionsHandler.SetRoleCommandPermission(role, command.Text, state);
|
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)
|
catch (ArgumentException exArg)
|
||||||
{
|
{
|
||||||
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
await e.Channel.SendMessage(exArg.Message).ConfigureAwait(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user