$cooldown

Sets a per-user cooldown for a command. This prevents users from spamming a command within a specified timeframe.

Usage:

$cooldown[time (default 5s);Error message;user id (optional)]

  • time: The duration of the cooldown. Defaults to 5 seconds if not provided. Examples: 10s, 1m, 2h, 1d.
  • Error message: The message displayed to the user if they try to use the command before the cooldown expires. You can use macros in this message (see below).
  • user id (optional): Apply the cooldown to a specific user ID instead of the user executing the command. Useful for moderator commands.

Example:

This example sets a 2-hour cooldown on a command that gives the user points. If the user tries to use the command before the cooldown expires, they will receive a message indicating how much time is left.

Member04/04/2025
!!exec $cooldown[2h;You can get points again after %time%]
$sendMessage[You received 100x points.]
Custom Command Bot 04/04/2025
You can get points again after 1 hour 54 minutes and 56 seconds

Usable Macros In Message:

These macros can be used in the Error message to provide dynamic information about the remaining cooldown time.

MacroDescriptionOutput Example
%time%Human-readable time remaining.5 days 1 hour 54 minutes and 56 seconds
%days%Days remaining.5
%hrs%Hours remaining.1
%mins%Minutes remaining.54
%secs%Seconds remaining.56
%timestamp%UNIX timestamp (in seconds) of cooldown expiration.1680711176
%relative%Discord's relative timestamp (auto-updates).

Note

You can send an embed as the error message using Message Curl Format.

Related Functions

Important

Place this code on the FIRST line of your command's code. If it's not the first line, the code before $cooldown will execute regardless of the cooldown.

Function difficulty Easy
Tags: Cooldown Wait Raid Limit Raid Limited