Class RequireBotPermissionAttribute
Requires the bot to have a specific permission in the channel a command is invoked in.
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public class RequireBotPermissionAttribute : PreconditionAttribute
Constructors
| Improve this Doc View SourceRequireBotPermissionAttribute(ChannelPermission)
Requires that the bot account to have a specific ChannelPermission.
Declaration
public RequireBotPermissionAttribute(ChannelPermission permission)
Parameters
Type | Name | Description |
---|---|---|
ChannelPermission | permission | The 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.
Declaration
public RequireBotPermissionAttribute(GuildPermission permission)
Parameters
Type | Name | Description |
---|---|---|
GuildPermission | permission | The 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
| Improve this Doc View SourceChannelPermission
Gets the specified ChannelPermission of the precondition.
Declaration
public ChannelPermission? ChannelPermission { get; }
Property Value
Type | Description |
---|---|
Nullable<ChannelPermission> |
GuildPermission
Gets the specified GuildPermission of the precondition.
Declaration
public GuildPermission? GuildPermission { get; }
Property Value
Type | Description |
---|---|
Nullable<GuildPermission> |
NotAGuildErrorMessage
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 |
Methods
| Improve this Doc View SourceCheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)
Checks if the commandInfo
command to be executed meets the precondition requirements.
Declaration
public override async Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo command, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | The context of the command. |
ICommandInfo | command | |
IServiceProvider | services | The service collection used for dependency injection. |
Returns
Type | Description |
---|---|
Task<PreconditionResult> |