Table of Contents

Class RequireRoleAttribute

Namespace
Signal.Application.Roles
Assembly
Signal.Application.dll

The sender must have at least one of the given roles, as decided by the registered IRoleProviders (by default: Signal:Commands:Roles, Signal:Commands:Admins for Admin, and Signal group admins for GroupAdmin).

public sealed class RequireRoleAttribute : PreconditionAttribute
Inheritance
RequireRoleAttribute
Inherited Members

Examples

[Command("ban"), RequireRole("moderator", Role.GroupAdmin)]
public Task BanAsync(Recipient member) => …;

Constructors

RequireRoleAttribute(params string[])

The sender must have at least one of the given roles, as decided by the registered IRoleProviders (by default: Signal:Commands:Roles, Signal:Commands:Admins for Admin, and Signal group admins for GroupAdmin).

public RequireRoleAttribute(params string[] roles)

Parameters

roles string[]

Acceptable roles; one is enough.

Examples

[Command("ban"), RequireRole("moderator", Role.GroupAdmin)]
public Task BanAsync(Recipient member) => …;

Properties

Roles

Acceptable roles; one is enough.

public IReadOnlyList<string> Roles { get; }

Property Value

IReadOnlyList<string>

Methods

CheckAsync(CommandContext, CancellationToken)

Checks whether the command may run.

public override ValueTask<PreconditionResult> CheckAsync(CommandContext context, CancellationToken cancellationToken)

Parameters

context CommandContext

The command context.

cancellationToken CancellationToken

Cancelled when the host shuts down.

Returns

ValueTask<PreconditionResult>

The check result.