$channelCooldown
Sets a cooldown for a command, per channel! This means the command can only be used again in the specific channel after the specified cooldown has expired.
Usage:
$channelCooldown[time (default is 5s);Error message]
- time: The cooldown duration. Defaults to 5 seconds if not provided. Examples:
10s
,1m
,2h
,1d
. - Error message: The message to send when a user tries to use the command before the cooldown expires.
Example:
In this example, the command will give the user 100 points. If they try to use the command again within 2 hours in the same channel, they will receive the error message: "You can get points again after [remaining time]".
Usable Macros in Error Message:
These macros can be used in your error message to provide dynamic information about the cooldown.
Macro | Description | Output Example |
---|---|---|
%time% | Replaced with the remaining time in a readable format. | 5 days 1 hour 54 minutes and 56 seconds |
%days% | The number of days remaining. | 5 |
%hrs% | The number of hours remaining. | 1 |
%mins% | The number of minutes remaining. | 54 |
%secs% | The number of seconds remaining. | 56 |
%timestamp% | Unix timestamp (seconds) for when the cooldown expires. | 1680711176 |
%relative% | Displays the remaining time using Discord's relative timestamp feature (updates automatically). | ![]() |
Note
You can send styled messages or embeds by using the Message Curl Format in the error message.
Related Functions
- $cooldown: Sets a cooldown for a command, per user.
- $serverCooldown: Sets a cooldown for a command, per server.
Important
Place the $channelCooldown
function on the FIRST line of your command's code. If it's not the first line, the code before it will execute regardless of the cooldown, and the cooldown won't apply correctly.