;acmdcds added to benefit ;cmdcd, permission system can now take aliases
This commit is contained in:
parent
3b8e9a6af7
commit
123b75b7c9
@ -55,9 +55,11 @@ namespace NadekoBot.Modules.Permissions.Classes
|
|||||||
if (string.IsNullOrWhiteSpace(commandText))
|
if (string.IsNullOrWhiteSpace(commandText))
|
||||||
throw new ArgumentNullException(nameof(commandText));
|
throw new ArgumentNullException(nameof(commandText));
|
||||||
|
|
||||||
|
var normalizedCmdTxt = commandText.Trim().ToUpperInvariant();
|
||||||
|
|
||||||
foreach (var com in NadekoBot.Client.GetService<CommandService>().AllCommands)
|
foreach (var com in NadekoBot.Client.GetService<CommandService>().AllCommands)
|
||||||
{
|
{
|
||||||
if (com.Text.ToLower().Equals(commandText.Trim().ToLower()))
|
if (com.Text.ToUpperInvariant().Equals(normalizedCmdTxt) || com.Aliases.Select(c=>c.ToUpperInvariant()).Contains(normalizedCmdTxt))
|
||||||
return com.Text;
|
return com.Text;
|
||||||
}
|
}
|
||||||
throw new NullReferenceException("That command does not exist.");
|
throw new NullReferenceException("That command does not exist.");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.Modules;
|
using Discord.Modules;
|
||||||
|
using NadekoBot.Classes;
|
||||||
using NadekoBot.Classes.JSONModels;
|
using NadekoBot.Classes.JSONModels;
|
||||||
using NadekoBot.Extensions;
|
using NadekoBot.Extensions;
|
||||||
using NadekoBot.Modules.Games.Commands;
|
using NadekoBot.Modules.Games.Commands;
|
||||||
@ -809,6 +810,24 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
await e.Channel.SendMessage("Something went terribly wrong - " + ex.Message).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(Prefix + "allcmdcooldowns")
|
||||||
|
.Alias(Prefix + "acmdcds")
|
||||||
|
.Description("Shows a list of all commands and their respective cooldowns.")
|
||||||
|
.Do(async e =>
|
||||||
|
{
|
||||||
|
ServerPermissions perms;
|
||||||
|
PermissionsHandler.PermissionsDict.TryGetValue(e.Server.Id, out perms);
|
||||||
|
if (perms == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!perms.CommandCooldowns.Any())
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage("`No command cooldowns set.`").ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await e.Channel.SendMessage(SearchHelper.ShowInPrettyCode(perms.CommandCooldowns.Select(c=>c.Key+ ": "+c.Value+" secs"),s=>$"{s,-30}",2)).ConfigureAwait(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user