Class CooldownAttribute
- Namespace
- Signal.Application.Commands.Preconditions
- Assembly
- Signal.Application.dll
Limits how often a command can be used. Runs after all other preconditions.
public sealed class CooldownAttribute : PreconditionAttribute
- Inheritance
-
CooldownAttribute
- Inherited Members
Constructors
CooldownAttribute(double)
Limits how often a command can be used. Runs after all other preconditions.
public CooldownAttribute(double seconds)
Parameters
secondsdoubleThe cooldown period in seconds.
Properties
Order
Execution order; lower values run first. Stateful checks such as cooldowns should run last.
public override int Order { get; }
Property Value
Period
The cooldown period.
public TimeSpan Period { get; }
Property Value
Scope
Who shares the cooldown. Default PerSender.
public CooldownScope Scope { get; set; }
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.