Class RequireRoleAttribute
Requires the user invoking the command to have a specified role.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
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
CheckPermissionsAsync(ICommandContext, CommandInfo, IServiceProvider)
Checks if the command
has the sufficient permission to be executed.
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
Parameters
context
ICommandContextThe context of the command.
command
CommandInfoThe command being executed.
services
IServiceProviderThe service collection used for dependency injection.