CooldownError
class in meocord/common Since 4.1.0
class CooldownError extends ErrorThrown when a @Cooldown blocks a call, so the handler does not run.
Catch it in a filter to answer the caller your own way. Without one, the built-in fallback answers only the caller,
with meocord.cooldown.until: the time the wait ends, which retryAt holds, as a Discord timestamp. A message
command is not answered, unless messages.dmOnCooldown tells its author in a direct message, once per wait.
Examples
@Catch(CooldownError)
export class CooldownFilter implements ExceptionFilter<CooldownError> {
async catch(error: CooldownError, context: ExecutionContext) {
const interaction = context.getInteraction()
if (interaction?.isRepliable()) {
await interaction.reply({ content: `You can do that again ${time(error.retryAt, 'R')}.`, flags: MessageFlags.Ephemeral })
}
}
}Members
constructor
new CooldownError(
retryAfterMs: number,
per: CooldownScope,
limit?: CooldownLimit | undefined,
)Parameters
| Name | Type | Description |
|---|---|---|
retryAfterMs | number | How long until the next call is allowed. |
per | CooldownScope | The scope of the cooldown that blocked the call. |
limit? | CooldownLimit | undefined | The limit of the cooldown that blocked the call, as |
limit
readonly limit?: CooldownLimit | undefinedper
readonly per: CooldownScoperetryAfterMs
readonly retryAfterMs: numberretryAt
readonly retryAt: DateWhen the next call is allowed: when the error was made, plus CooldownError.retryAfterMs.