From 234a94e5fceb3710fa8203dc91f290c699780ced Mon Sep 17 00:00:00 2001 From: appelemac Date: Thu, 19 May 2016 19:58:59 +0200 Subject: [PATCH 1/2] ;cm defaults to current channel --- .../Modules/Permissions/PermissionsModule.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Modules/Permissions/PermissionsModule.cs b/NadekoBot/Modules/Permissions/PermissionsModule.cs index 898560b7..65ac5fdd 100644 --- a/NadekoBot/Modules/Permissions/PermissionsModule.cs +++ b/NadekoBot/Modules/Permissions/PermissionsModule.cs @@ -372,12 +372,12 @@ namespace NadekoBot.Modules.Permissions .Description("Sets a module's permission at the channel level.\n**Usage**: ;cm [module_name] enable [channel_name]") .Do(async e => { - try + try { var module = PermissionHelper.ValidateModule(e.GetArg("module")); var state = PermissionHelper.ValidateBool(e.GetArg("bool")); - - if (e.GetArg("channel")?.ToLower() == "all") + var channelArg = e.GetArg("channel"); + if (channelArg?.ToLower() == "all") { foreach (var channel in e.Server.TextChannels) { @@ -385,9 +385,14 @@ namespace NadekoBot.Modules.Permissions } await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false); } - else + else if (string.IsNullOrWhiteSpace(channelArg)) { - var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); + PermissionsHandler.SetChannelModulePermission(e.Channel, module, state); + await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{e.Channel.Name}** channel.").ConfigureAwait(false); + } + else + { + var channel = PermissionHelper.ValidateChannel(e.Server, channelArg); PermissionsHandler.SetChannelModulePermission(channel, module, state); await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false); From d9efa92124a7a4285b804e41ae8e0a7f1914ace0 Mon Sep 17 00:00:00 2001 From: appelemac Date: Thu, 19 May 2016 20:45:00 +0200 Subject: [PATCH 2/2] acm as well --- NadekoBot/Modules/Permissions/PermissionsModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Permissions/PermissionsModule.cs b/NadekoBot/Modules/Permissions/PermissionsModule.cs index 65ac5fdd..ebba4919 100644 --- a/NadekoBot/Modules/Permissions/PermissionsModule.cs +++ b/NadekoBot/Modules/Permissions/PermissionsModule.cs @@ -559,7 +559,8 @@ namespace NadekoBot.Modules.Permissions try { var state = PermissionHelper.ValidateBool(e.GetArg("bool")); - var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel")); + var chArg = e.GetArg("channel"); + var channel = string.IsNullOrWhiteSpace(chArg) ? e.Channel :PermissionHelper.ValidateChannel(e.Server, chArg); foreach (var module in NadekoBot.Client.GetService().Modules) { PermissionsHandler.SetChannelModulePermission(channel, module.Name, state);