Table of Contents

Class RequireRoleAttribute

Namespace
HeyBox.Interactions
Assembly
HeyBox.Net.Interactions.dll

要求调用命令的用户拥有指定的角色。

public class RequireRoleAttribute : PreconditionAttribute
Inheritance
RequireRoleAttribute
Inherited Members

Constructors

RequireRoleAttribute(ulong)

要求调用命令的用户拥有特定角色。

public RequireRoleAttribute(ulong roleId)

Parameters

roleId ulong

需要用户拥有的角色 ID。

Properties

NotAGuildErrorMessage

获取或设置如果由于在非群组频道运行而导致先决条件失败时的错误消息。

public string? NotAGuildErrorMessage { get; set; }

Property Value

string

RoleId

获取此先决条件指定的角色 ID。

public ulong RoleId { get; }

Property Value

ulong

Methods

CheckRequirementsAsync(IInteractionContext, ICommandInfo, IServiceProvider?)

检查 commandInfo 所代表的命令是否满足先决条件。

public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider? services)

Parameters

context IInteractionContext

命令的上下文。

commandInfo ICommandInfo

被执行的命令。

services IServiceProvider

用于依赖注入的服务集合。

Returns

Task<PreconditionResult>