Class DoHierarchyCheckAttribute
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Ensures that command parameters are passed within a correct hierarchical context.
public class DoHierarchyCheckAttribute : ParameterPreconditionAttribute
- Inheritance
-
DoHierarchyCheckAttribute
- Inherited Members
Remarks
Useful for performing hierarchical operations within a guild, such as managing roles or users.
warning
This supports IRole, IGuildUser, and IUser parameter types.
Properties
ErrorMessage
Gets the error message to be returned if execution context doesn't pass the precondition check.
public override string ErrorMessage { get; }
Property Value
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.
Exceptions
- ArgumentOutOfRangeException
Thrown when the parameter type is not supported by this precondition attribute.
NotAGuildErrorMessage
Gets or sets the error message displayed when the command is used outside of a guild.
public string NotAGuildErrorMessage { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
Thrown when the parameter type is not supported by this precondition attribute.
Methods
CheckRequirementsAsync(IInteractionContext, IParameterInfo, object, IServiceProvider)
Checks whether the condition is met before execution of the command.
public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, IParameterInfo parameterInfo, object value, IServiceProvider services)
Parameters
context
IInteractionContextThe context of the command.
parameterInfo
IParameterInfoThe parameter of the command being checked against.
value
objectThe raw value of the parameter.
services
IServiceProviderThe service collection used for dependency injection.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown when the parameter type is not supported by this precondition attribute.