Class RequireBotPermissionAttribute
Requires the bot to have a specific permission in the channel a command is invoked in.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class RequireBotPermissionAttribute : PreconditionAttribute
- Inheritance
-
RequireBotPermissionAttribute
- Inherited Members
Constructors
RequireBotPermissionAttribute(ChannelPermission)
Requires that the bot account to have a specific ChannelPermission.
public RequireBotPermissionAttribute(ChannelPermission permission)
Parameters
permissionChannelPermissionThe ChannelPermission that the bot must have. Multiple permissions can be specified by ORing the permissions together.
RequireBotPermissionAttribute(GuildPermission)
Requires the bot account to have a specific GuildPermission.
public RequireBotPermissionAttribute(GuildPermission permission)
Parameters
permissionGuildPermissionThe GuildPermission that the bot 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
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.
public override string ErrorMessage { get; set; }
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
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
contextICommandContextThe context of the command.
commandCommandInfoThe command being executed.
servicesIServiceProviderThe service collection used for dependency injection.