diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs index 9abe6de32..3cd964a86 100644 --- a/src/Discord.Net.Commands/Info/CommandInfo.cs +++ b/src/Discord.Net.Commands/Info/CommandInfo.cs @@ -63,6 +63,9 @@ namespace Discord.Commands _action = builder.Callback; } + public IEnumerable GetPreconditions() where TPrecondition : PreconditionAttribute => + Preconditions.Where(x => x.GetType() == typeof(TPrecondition)).Cast(); + public async Task CheckPreconditionsAsync(ICommandContext context, IDependencyMap map = null) { if (map == null) diff --git a/src/Discord.Net.Commands/Info/ModuleInfo.cs b/src/Discord.Net.Commands/Info/ModuleInfo.cs index a2094df65..ed385564e 100644 --- a/src/Discord.Net.Commands/Info/ModuleInfo.cs +++ b/src/Discord.Net.Commands/Info/ModuleInfo.cs @@ -20,6 +20,9 @@ namespace Discord.Commands public ModuleInfo Parent { get; } public bool IsSubmodule => Parent != null; + public IEnumerable GetPreconditions() where TPrecondition : PreconditionAttribute => + Preconditions.Where(x => x.GetType() == typeof(TPrecondition)).Cast(); + internal ModuleInfo(ModuleBuilder builder, CommandService service, ModuleInfo parent = null) { Service = service;