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
rolesstring[]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
Methods
CheckAsync(CommandContext, CancellationToken)
Checks whether the command may run.
public override ValueTask<PreconditionResult> CheckAsync(CommandContext context, CancellationToken cancellationToken)
Parameters
contextCommandContextThe command context.
cancellationTokenCancellationTokenCancelled when the host shuts down.
Returns
- ValueTask<PreconditionResult>
The check result.