Skip to content
Interfacecorev0.14.0

CooldownOptions

Options for Cooldown. per sets the bucket that the window applies to and limit the uses allowed per window. notice replaces the refusal.

interface CooldownOptions
// one use per channel, refusing with your own Notice class
class SlowDown extends Notice {
    public constructor(resetAt: EpochMs) {
        super(`Slow down. Try again <t:${toEpochSeconds(resetAt)}:R>.`);
    }
}

Cooldown('10s', { per: 'channel', notice: SlowDown });
// five uses per minute, per user
Cooldown('1m', { limit: 5 });

Properties

limit

Uses allowed inside one window before the gate refuses.

limit?: number

Default:1

notice

Your Notice class, constructed with the epoch ms the key frees up and thrown in place of the default refusal.

notice?: NoticeConstructor<[resetAt: EpochMs]>

per

The bucket the cooldown window applies to. 'user' scopes by user ID (falls back to global when the source doesn't have a user id). 'guild' scopes by guild ID (falls back to global when the source doesn't have a guild), and 'channel' scopes by channel ID (falls back to global when the source doesn't have a channel).

Default:'user'