Search Results for

    Show / Hide Table of Contents

    Class RequireUserPermissionAttribute

    Requires the user that requested the interaction to have a certain permissions.

    Inheritance
    System.Object
    System.Attribute
    InteractionRequirementAttribute
    RequireUserPermissionAttribute
    Inherited Members
    System.Attribute.Equals(System.Object)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetHashCode()
    System.Attribute.IsDefaultAttribute()
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.Match(System.Object)
    System.Attribute.TypeId
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Color_Chan.Discord.Commands.Attributes.ProvidedRequirements
    Assembly: Color-Chan.Discord.Commands.dll
    Syntax
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
    public class RequireUserPermissionAttribute : InteractionRequirementAttribute
    Examples

    This example limits all the slash commands in the PongCommands slash command module to users that have the BanMembers and KickMembers permission. You can also put the RequireUserPermissionAttribute on a method if you only want to have it on a specific command.

    [RequireUserPermission(DiscordGuildPermission.BanMembers | DiscordGuildPermission.KickMembers)]
    public class PongCommands : SlashCommandModule
    {
        [SlashCommand("ping", "Ping Pong!")]
        public Task<IDiscordInteractionResponse> PongAsync()
        {
            // Command code...
        }
    }

    Constructors

    | Improve this Doc View Source

    RequireUserPermissionAttribute(DiscordPermission)

    Initializes a new instance of UserRateLimitAttribute.

    Declaration
    public RequireUserPermissionAttribute(DiscordPermission requiredPermission)
    Parameters
    Type Name Description
    DiscordPermission requiredPermission

    The DiscordPermission the user is required to have for this command/command group.

    Methods

    | Improve this Doc View Source

    CheckRequirementAsync(IInteractionContext, IServiceProvider)

    Checks if a specific requirement for a interaction request has met.

    Declaration
    public override Task<Result> CheckRequirementAsync(IInteractionContext context, IServiceProvider services)
    Parameters
    Type Name Description
    IInteractionContext context

    The IInteractionContext of the interaction request.

    System.IServiceProvider services

    The System.IServiceProvider containing all the necessary dependencies for the interaction request.

    Returns
    Type Description
    System.Threading.Tasks.Task<Result>

    The result of the interaction request requirement.

    Overrides
    InteractionRequirementAttribute.CheckRequirementAsync(IInteractionContext, IServiceProvider)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX