Search Results for

    Show / Hide Table of Contents

    Class RequireBotPermissionAttribute

    Requires the bot to have a specific permission in the channel a command is invoked in.

    Inheritance
    Object
    PreconditionAttribute
    RequireBotPermissionAttribute
    Inherited Members
    PreconditionAttribute.Group
    PreconditionAttribute.ErrorMessage
    Namespace: Discord.Interactions
    Assembly: Discord.Net.Interactions.dll
    Syntax
    public class RequireBotPermissionAttribute : PreconditionAttribute

    Constructors

    | Improve this Doc View Source

    RequireBotPermissionAttribute(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.

    | Improve this Doc View Source

    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 Source

    ChannelPermission

    Gets the specified ChannelPermission of the precondition.

    Declaration
    public ChannelPermission? ChannelPermission { get; }
    Property Value
    Type Description
    Nullable<ChannelPermission>
    | Improve this Doc View Source

    GuildPermission

    Gets the specified GuildPermission of the precondition.

    Declaration
    public GuildPermission? GuildPermission { get; }
    Property Value
    Type Description
    Nullable<GuildPermission>
    | Improve this Doc View Source

    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 Source

    CheckRequirementsAsync(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>
    Overrides
    PreconditionAttribute.CheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider)

    Theme

    • Improve this Doc
    • View Source
    In This Article
    Back to top Discord.Net (c) 2015-2022 3.7.2