# Cooldown

`function` in `core` · v0.14.0

<https://seedcord.org/docs/packages/core/0.14.0/functions/cooldown>

Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, and a string is
a duration like `30m` or `24h`. A later refusal never burns the cooldown
because the slot is charged in commit, only after the whole gate set passes.
If two requests in one process pass the check together, the commit refuses the one that exceeds `limit`.
The key combines the handler's route with the window settings, keeping two different handlers on separate
windows. Replace the refusal with [`notice`](/docs/packages/core/0.14.0/interfaces/cooldown-options#notice).

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

Allows `limit` uses per window, scoped by `per`. A number `duration` is **seconds**, and a string is
a duration like `30m` or `24h`. A later refusal never burns the cooldown
because the slot is charged in commit, only after the whole gate set passes.
If two requests in one process pass the check together, the commit refuses the one that exceeds `limit`.
The key combines the handler's route with the window settings, keeping two different handlers on separate
windows. Replace the refusal with [`notice`](/docs/packages/core/0.14.0/interfaces/cooldown-options#notice).

Parameters.

- `duration` `number | ValidDuration<TDuration>` — A number is seconds, and a string is a duration like `30m` or `24h`.
- `options?` `CooldownOptions` — Sets the scope with `per`, the uses per window with `limit`, and the refusal with `notice`.

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