Class PreconditionAttribute
Requires the module or class to pass the specified precondition before execution can begin.
Inheritance
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public abstract class PreconditionAttribute : Attribute
Properties
| Improve this Doc View SourceErrorMessage
Gets the error message to be returned if execution context doesn't pass the precondition check.
Declaration
public virtual string ErrorMessage { get; }
Property Value
Type | Description |
---|---|
String |
Remarks
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.
Group
Gets the group that this precondition belongs to.
Declaration
public string Group { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
Discord.Preconditions of the same group require only one of the preconditions to pass in order to be successful (A || B). Specifying Group = null or not at all will require all preconditions to pass, just like normal (A && B).
Methods
| Improve this Doc View SourceCheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)
Checks if the commandInfo
command to be executed meets the precondition requirements.
Declaration
public abstract Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | The context of the command. |
ICommandInfo | commandInfo | The command being executed. |
IServiceProvider | services | The service collection used for dependency injection. |
Returns
Type | Description |
---|---|
Task<PreconditionResult> |