Class RequireUserPermissionAttribute
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Requires the user invoking the command to have a specified permission.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RequireUserPermissionAttribute : PreconditionAttribute
- Inheritance
-
RequireUserPermissionAttribute
- Inherited Members
Constructors
RequireUserPermissionAttribute(ChannelPermission)
Requires that the user invoking the command to have a specific ChannelPermission.
public RequireUserPermissionAttribute(ChannelPermission channelPermission)
Parameters
channelPermission
ChannelPermissionThe ChannelPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.
RequireUserPermissionAttribute(GuildPermission)
Requires that the user invoking the command to have a specific GuildPermission.
public RequireUserPermissionAttribute(GuildPermission guildPermission)
Parameters
guildPermission
GuildPermissionThe GuildPermission that the user must have. Multiple permissions can be specified by ORing the permissions together.
Remarks
This precondition will always fail if the command is being invoked in a IPrivateChannel.
Properties
ChannelPermission
Gets the specified ChannelPermission of the precondition.
public ChannelPermission? ChannelPermission { get; }
Property Value
GuildPermission
Gets the specified GuildPermission of the precondition.
public GuildPermission? GuildPermission { get; }
Property Value
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
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.