Merge pull request #300 from appelemac/patch-3
;cm and ;acm default to current channel
This commit is contained in:
commit
b010da3c8c
@ -376,8 +376,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
||||||
|
var channelArg = e.GetArg("channel");
|
||||||
if (e.GetArg("channel")?.ToLower() == "all")
|
if (channelArg?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var channel in e.Server.TextChannels)
|
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);
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on **ALL** channels.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
else if (string.IsNullOrWhiteSpace(channelArg))
|
||||||
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
var channel = PermissionHelper.ValidateChannel(e.Server, channelArg);
|
||||||
|
|
||||||
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
PermissionsHandler.SetChannelModulePermission(channel, module, state);
|
||||||
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
await e.Channel.SendMessage($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
@ -554,7 +559,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
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<ModuleService>().Modules)
|
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
||||||
{
|
{
|
||||||
PermissionsHandler.SetChannelModulePermission(channel, module.Name, state);
|
PermissionsHandler.SetChannelModulePermission(channel, module.Name, state);
|
||||||
|
Loading…
Reference in New Issue
Block a user