You can now use actualcustomreactions as a module name to enable/disable actual custom reactions, as opposed to commands to manage them which are in CustomReactions module

This commit is contained in:
Kwoth 2017-04-10 19:56:10 +02:00
parent a3bd89460b
commit 06ca1c5f8f
5 changed files with 29 additions and 6 deletions

View File

@ -181,7 +181,7 @@ namespace NadekoBot.Modules.Games
return old;
});
}
#if !GLOBAL_NADEKO
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.ManageMessages)]
@ -218,6 +218,7 @@ namespace NadekoBot.Modules.Games
await ReplyConfirmLocalized("curgen_disabled").ConfigureAwait(false);
}
}
#endif
private static KeyValuePair<string, ImmutableArray<byte>> GetRandomCurrencyImage()
{

View File

@ -52,7 +52,7 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[OwnerOnly]
public async Task Gmod(ModuleInfo module)
public async Task Gmod(ModuleOrCrInfo module)
{
var moduleName = module.Name.ToLowerInvariant();
if (BlockedModules.Add(moduleName))

View File

@ -363,7 +363,7 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task SrvrMdl(ModuleInfo module, PermissionAction action)
public async Task SrvrMdl(ModuleOrCrInfo module, PermissionAction action)
{
await AddPermissions(Context.Guild.Id, new Permissionv2
{
@ -419,7 +419,7 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task UsrMdl(ModuleInfo module, PermissionAction action, [Remainder] IGuildUser user)
public async Task UsrMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] IGuildUser user)
{
await AddPermissions(Context.Guild.Id, new Permissionv2
{
@ -480,7 +480,7 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task RoleMdl(ModuleInfo module, PermissionAction action, [Remainder] IRole role)
public async Task RoleMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] IRole role)
{
if (role == role.Guild.EveryoneRole)
return;
@ -542,7 +542,7 @@ namespace NadekoBot.Modules.Permissions
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
public async Task ChnlMdl(ModuleInfo module, PermissionAction action, [Remainder] ITextChannel chnl)
public async Task ChnlMdl(ModuleOrCrInfo module, PermissionAction action, [Remainder] ITextChannel chnl)
{
await AddPermissions(Context.Guild.Id, new Permissionv2
{

View File

@ -112,6 +112,7 @@ namespace NadekoBot
CommandService.AddTypeReader<CommandInfo>(new CommandTypeReader());
CommandService.AddTypeReader<CommandOrCrInfo>(new CommandOrCrTypeReader());
CommandService.AddTypeReader<ModuleInfo>(new ModuleTypeReader());
CommandService.AddTypeReader<ModuleOrCrInfo>(new ModuleOrCrTypeReader());
CommandService.AddTypeReader<IGuild>(new GuildTypeReader());

View File

@ -17,4 +17,25 @@ namespace NadekoBot.TypeReaders
return Task.FromResult(TypeReaderResult.FromSuccess(module));
}
}
public class ModuleOrCrTypeReader : TypeReader
{
public override Task<TypeReaderResult> Read(ICommandContext context, string input)
{
input = input.ToLowerInvariant();
var module = NadekoBot.CommandService.Modules.GroupBy(m => m.GetTopLevelModule()).FirstOrDefault(m => m.Key.Name.ToLowerInvariant() == input)?.Key;
if (module == null && input != "actualcustomreactions")
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No such module found."));
return Task.FromResult(TypeReaderResult.FromSuccess(new ModuleOrCrInfo
{
Name = input,
}));
}
}
public class ModuleOrCrInfo
{
public string Name { get; set; }
}
}