Skip to main content

Class RequireUserPermissionAttribute

Requires the user invoking the command to have a specified permission.

Assembly: Discord.Net.Commands.dll​
View Source​
Declaration
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RequireUserPermissionAttribute : PreconditionAttribute, _Attribute

Properties​

GuildPermission​

Gets the specified Discord.GuildPermission of the precondition.

View Source​
Declaration
public GuildPermission? GuildPermission { get; }

ChannelPermission​

Gets the specified Discord.ChannelPermission of the precondition.

View Source​
Declaration
public ChannelPermission? ChannelPermission { get; }

ErrorMessage​

When overridden in a derived class, uses the supplied string as the error message if the precondition doesn't pass. Setting this for a class that doesn't override this property is a no-op.

View Source​
Declaration
public override string ErrorMessage { get; set; }

NotAGuildErrorMessage​

Gets or sets the error message if the precondition fails due to being run outside of a Guild channel.

View Source​
Declaration
public string NotAGuildErrorMessage { get; set; }

Methods​

CheckPermissionsAsync(ICommandContext, CommandInfo, IServiceProvider)​

Checks if the <code data-dev-comment-type="paramref" class="paramref">command</code> has the sufficient permission to be executed.

View Source​
Declaration
public override Task<PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
Returns​

System.Threading.Tasks.Task<Discord.Commands.PreconditionResult>

Parameters​
TypeNameDescription
Discord.Commands.ICommandContextcontextThe context of the command.
Discord.Commands.CommandInfocommandThe command being executed.
System.IServiceProviderservicesThe service collection used for dependency injection.

Implements​

  • System.Runtime.InteropServices._Attribute