Moderation
clear
$clear
Deletes a specified number of messages in the channel.
Syntax
$clear[amount;(userID);(removePinned)]
$clear
The $clear function deletes a specified number of messages in the current channel. This function is dedicated to bulk-deleting messages (moderation), not to be confused with the variable function $clear of the same name. The bot must have the ManageMessages permission.
Syntax
$clear[amount;(userID);(removePinned)]
Parameters
| Parameter | Description |
|---|---|
amount |
Number of messages to delete (1-100). Required. |
userID |
Optional. Filter: only deletes messages from this user. |
removePinned |
Optional. "yes" to include pinned messages. Default is "no". |
Return value
None. The messages are deleted.
Examples
Simple deletion
$clear[50]
$sendMessage[🧹 50 messages have been cleared.]
Targeted deletion by user
$clear[100;$mentioned[1]]
$sendMessage[🧹 Messages from <@$mentioned[1]> deleted.]
Clear command with verification
$if[$argsCount<1]
$sendMessage[Usage: !clear <number>]
$stop
$endif
$if[$isAdmin==true]
$clear[$message[1]]
$sendMessage[🧹 $message[1] messages deleted.]
$else
$sendMessage[Permission denied.]
$endif
Deletion including pinned messages
$clear[10;;yes]
$sendMessage[10 messages deleted (pinned included).]
Notes
- The bot must have the
ManageMessagespermission. - Maximum 100 messages per call (Discord API limitation).
- Messages older than 14 days cannot be deleted by the Discord API.
removePinneddefaults to"no": pinned messages are ignored.- If
userIDis omitted, leave the semicolon field empty (e.g.,$clear[10;;yes]). - This
$clearfunction is dedicated to moderation. To clear a variable, see$clearin the Variables category.