Table of Contents

Class DoHierarchyCheckAttribute

Namespace
Discord.Commands
Assembly
Discord.Net.Commands.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 string ErrorMessage { get; set; }

Property Value

string

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

string

Exceptions

ArgumentOutOfRangeException

Thrown when the parameter type is not supported by this precondition attribute.

Methods

CheckPermissionsAsync(ICommandContext, ParameterInfo, object, IServiceProvider)

Checks whether the condition is met before execution of the command.

public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, ParameterInfo parameterInfo, object value, IServiceProvider services)

Parameters

context ICommandContext

The context of the command.

parameterInfo ParameterInfo
value object

The raw value of the parameter.

services IServiceProvider

The service collection used for dependency injection.

Returns

Task<PreconditionResult>

Exceptions

ArgumentOutOfRangeException

Thrown when the parameter type is not supported by this precondition attribute.

See Also