Search Results for

    Show / Hide Table of Contents

    Class RequireRoleAttribute

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

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

    Constructors

    | Improve this Doc View Source

    RequireRoleAttribute(String)

    Requires that the user invoking the command to have a specific Role.

    Declaration
    public RequireRoleAttribute(string roleName)
    Parameters
    Type Name Description
    String roleName

    Name of the role that the user must have.

    | Improve this Doc View Source

    RequireRoleAttribute(UInt64)

    Requires that the user invoking the command to have a specific Role.

    Declaration
    public RequireRoleAttribute(ulong roleId)
    Parameters
    Type Name Description
    UInt64 roleId

    Id of the role that the user must have.

    Properties

    | 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
    | Improve this Doc View Source

    RoleId

    Gets the specified Role ID of the precondition.

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

    RoleName

    Gets the specified Role name of the precondition.

    Declaration
    public string RoleName { get; }
    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 Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services)
    Parameters
    Type Name Description
    IInteractionContext context

    The context of the command.

    ICommandInfo commandInfo

    The command being executed.

    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