Table of Contents

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

seconds double

The 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

int

Period

The cooldown period.

public TimeSpan Period { get; }

Property Value

TimeSpan

Scope

Who shares the cooldown. Default PerSender.

public CooldownScope Scope { get; set; }

Property Value

CooldownScope

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.