cooldownMessage
function in meocord/common Since 4.1.0
cooldownMessage(retryAfterMs: number): stringThe 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 wait is formatDuration's, rounded up so it never says less than the wait, and 1s at the least. A wait
that is no finite number, as a custom store may answer for a call it refuses for good, reads "Slow down: try again
later.", meocord.cooldown.later.
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
| Name | Type |
|---|---|
retryAfterMs | number |
How long until the next call is allowed. | |
Returns
stringThe message, in English.
Examples
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.'