using System; using System.Threading.Tasks; namespace Discord.Commands { /// /// Requires the module or class to pass the specified precondition before execution can begin. /// /// [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true, Inherited = true)] public abstract class PreconditionAttribute : Attribute { /// /// Specifies a group that this precondition belongs to. /// /// /// of the same group require only one of the preconditions to pass in order to /// be successful (A || B). Specifying = null or not at all will /// require *all* preconditions to pass, just like normal (A && B). /// public string Group { get; set; } = null; /// /// When overridden in a derived class, uses the supplied string /// as the error message if the precondition doesn't pass. /// Setting this for a class that doesn't override /// this property is a no-op. /// public virtual string ErrorMessage { get { return null; } set { } } /// /// Checks if the has the sufficient permission to be executed. /// /// The context of the command. /// The command being executed. /// The service collection used for dependency injection. public abstract Task CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services); } }