# Cooldown

`function` in `core` · v0.1.0-next.5

<https://docs.seedcord.org/packages/core/0.1.0-next.5/functions/cooldown>

Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, a string is a duration like `30m` or `24h`. An unparseable string throws a **SeedcordTypeError** at construction. 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, so two different handlers keep separate windows. Reword the refusal with [`message`](/packages/core/0.1.0-next.5/interfaces/cooldown-options#message) or replace it with [`notice`](/packages/core/0.1.0-next.5/interfaces/cooldown-options#notice).

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

Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, a string is a duration like `30m` or `24h`. An unparseable string throws a **SeedcordTypeError** at construction. 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, so two different handlers keep separate windows. Reword the refusal with [`message`](/packages/core/0.1.0-next.5/interfaces/cooldown-options#message) or replace it with [`notice`](/packages/core/0.1.0-next.5/interfaces/cooldown-options#notice).

Parameters.

- `duration` `number | ValidDuration` — A number is seconds, a string is a duration like `30m` or `24h`. An unparseable string throws a **SeedcordTypeError**.
- `options?` `CooldownOptions` — Sets the scope with `per`, the uses per window with `limit`, and the refusal text with `message` or `notice`.

Returns `EffectGate<GateContextBase, 'Cooldown'>`.
