Class RequireRoleAttribute
Requires the user invoking the command to have a specified role.
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public class RequireRoleAttribute : PreconditionAttribute
Constructors
| Improve this Doc View SourceRequireRoleAttribute(String)
Requires that the user invoking the command to have a specific Role.
Declaration
public RequireRoleAttribute(string roleName)
Parameters
Type | Name | Description |
---|---|---|
String | roleName | Name of the role that the user must have. |
RequireRoleAttribute(UInt64)
Requires that the user invoking the command to have a specific Role.
Declaration
public RequireRoleAttribute(ulong roleId)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | roleId | Id of the role that the user must have. |
Properties
| Improve this Doc View SourceNotAGuildErrorMessage
Gets or sets the error message if the precondition fails due to being run outside of a Guild channel.
Declaration
public string NotAGuildErrorMessage { get; set; }
Property Value
Type | Description |
---|---|
String |
RoleId
Gets the specified Role ID of the precondition.
Declaration
public ulong? RoleId { get; }
Property Value
Type | Description |
---|---|
Nullable<UInt64> |
RoleName
Gets the specified Role name of the precondition.
Declaration
public string RoleName { get; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceCheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)
Checks if the commandInfo
command to be executed meets the precondition requirements.
Declaration
public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | The context of the command. |
ICommandInfo | commandInfo | The command being executed. |
IServiceProvider | services | The service collection used for dependency injection. |
Returns
Type | Description |
---|---|
Task<PreconditionResult> |