Skip to content
GitHub

cooldownMessage

function in meocord/common Since 4.1.0

cooldownMessage(retryAfterMs: number): string

The wait before a cooldown allows another call, in plain English, such as "Slow down: try again in 12s.": the message of a CooldownError, for logs and tests.

The answer a caller sees is meocord.cooldown.until instead, with the time the wait ends as a Discord timestamp, which the reader's client words in their language and counts down; translateError gives it.

Parameters

NameTypeDescription
retryAfterMsnumber

How long until the next call is allowed.

Returns

string

The message, in English.

Examples

TypeScript
cooldownMessage(12_000) // 'Slow down: try again in 12s.'
cooldownMessage(90_000) // 'Slow down: try again in 1m 30s.'
cooldownMessage(86_340_000) // 'Slow down: try again in 23h 59m.'