Skip to content

Cooldowns

cooldown #

cooldown(
    capacity: int,
    period: timedelta,
    *,
    callback: CooldownCallbackT = _default_callback,
    bucket: BucketCallbackT = _default_bucket
) -> Callable[[Context], Awaitable[HookResult | None]]

Ratelimit implementation using a sliding window.

PARAMETER DESCRIPTION
capacity

The amount of times the command can be used within the period.

TYPE: int

period

The period of time, in seconds, between cooldown resets.

TYPE: timedelta

callback

Callback for when a user is ratelimited.

TYPE: CooldownCallbackT DEFAULT: _default_callback

bucket

Callback that returns a key for a bucket.

TYPE: BucketCallbackT DEFAULT: _default_bucket