Skip to content
Functioncorev0.11.0

Cooldown

Allows limit uses per window, scoped by per. A number duration is seconds, and a string is a duration like 30m or 24h. The slot is charged in commit, only after the whole gate set passes, so a later refusal never burns the cooldown. That split also means two requests racing the same key can both pass before either charges the slot. The key combines the handler's route with the window settings, keeping two different handlers on separate windows. Reword the refusal with message or replace it with notice.

Throws:

  • A SeedcordTypeError when duration is a string that doesn't parse.

  • A SeedcordRangeError when duration is zero or negative.

See also:the @Gated decorator from your transport package, IRateLimiter

Cooldown(
    duration: number | ValidDuration,
    options?: CooldownOptions
): EffectGate<GateContextBase, "Cooldown">

duration

duration: number | ValidDuration

A number is seconds, and a string is a duration like 30m or 24h.

options?

options?: CooldownOptions

Sets the scope with per, the uses per window with limit, and the refusal text with message or notice.