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
roleNamestringName 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
roleIdulongId 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
contextIInteractionContextThe context of the command.
commandInfoICommandInfoThe command being executed.
servicesIServiceProviderThe service collection used for dependency injection.