Class RequireRoleAttribute
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Requires the user invoking the command to have a specified role.
public class RequireRoleAttribute : PreconditionAttribute
- Inheritance
-
RequireRoleAttribute
- Inherited Members
Constructors
RequireRoleAttribute(string)
Requires that the user invoking the command to have a specific Role.
public RequireRoleAttribute(string roleName)
Parameters
roleName
stringName of the role that the user must have.
RequireRoleAttribute(ulong)
Requires that the user invoking the command to have a specific Role.
public RequireRoleAttribute(ulong roleId)
Parameters
roleId
ulongId of the role that the user must have.
Properties
NotAGuildErrorMessage
Gets or sets the error message if the precondition fails due to being run outside of a Guild channel.
public string NotAGuildErrorMessage { get; set; }
Property Value
RoleId
Gets the specified Role ID of the precondition.
public ulong? RoleId { get; }
Property Value
RoleName
Gets the specified Role name of the precondition.
public string RoleName { get; }
Property Value
Methods
CheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)
Checks if the commandInfo
command to be executed meets the precondition requirements.
public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services)
Parameters
context
IInteractionContextThe context of the command.
commandInfo
ICommandInfoThe command being executed.
services
IServiceProviderThe service collection used for dependency injection.