How to bulk delete Discord messages with a bot
For a small cleanup of recent server messages, the Free Moderation module provides purge. Run !purge with an amount in the channel you want to clean, optionally mentioning a user to filter the fetched messages. Check the channel and permissions first: deletion is immediate. This command does not wipe a whole channel’s history and does not delete direct messages.
Start freeStart free. Pro is $9.99/month.
Before you start
- Have an online bot with Moderation enabled in your server. Your account needs Manage Messages, and the bot needs Manage Messages plus View Channel, Read Message History and Send Messages in the target channel.
- Use a disposable test channel containing only messages you created for this check. Purge has no preview or confirmation step, so do not experiment in a channel with conversations people need to keep.
Enable Moderation and check channel permissions
In the bot’s Modules tab, enable Moderation and wait for the bot to be online. In Discord, inspect the target channel’s permissions for both your staff role and the bot. Purge requires the caller to have Manage Messages; being able to send messages is not enough. Discord must also allow the bot to fetch and delete messages in that channel.
Channel permission overwrites can block the bot even when its server role looks correct. Give it View Channel and Read Message History to fetch the recent messages, Manage Messages to remove other users’ messages, and Send Messages to post the result. Its result uses an embed, so allow Embed Links too. Keep this ability with trusted moderators who understand deletion is irreversible.
Use !purge <amount> [@user]
For a small test, type `!purge 5` in the disposable channel. The amount must be an integer from 1 through 100. Replace ! if your bot has a different prefix. The registered aliases are `!clear` and `!prune`, with the same amount and optional user argument. Prefix commands depend on Message Content Intent; follow the builder’s checklist when enabling the module.
To restrict deletion to one author within the fetched recent batch, use `!purge 5 @Alex`, selecting the actual user mention in Discord. This does not search the entire channel for five messages by Alex: the bot fetches a recent batch and then filters it by that user. If the person wrote fewer eligible messages in that batch, fewer are removed. It operates in the channel where you invoke it, not across the server.
Understand the 100-message and 14-day boundaries
Discord’s bulk-delete operation allows at most 100 messages in a request and refuses messages older than 14 days. This module filters out messages that are 14 days old or older before bulk deletion. Old conversations remain in place; requesting a larger amount cannot bypass that age boundary. Purge has no whole-channel-history wipe or DM deletion mode.
There is a current counting caveat: although the amount input accepts 1–100, the implementation fetches amount plus one after attempting to delete the prefix-command message. When that command message has already been removed, an unfiltered !purge 5 can therefore remove six recent messages. At amount 100, the fetch asks for 101 and can fail against Discord’s request limit. Treat the amount as a batch input, not an exact deletion guarantee; use small batches only where an extra deletion is acceptable.
Check the actual result before another batch
On success the bot reports “Deleted [count] message(s)” in an embed, with the user’s tag added when a user filter was supplied. The count is the actual number returned by the deletion operation. The confirmation is removed after about three seconds. Inspect the remaining test messages while it is visible rather than assuming the requested amount exactly matched what disappeared.
If the command fails, check its error and channel permissions before retrying. Messages can be skipped because they are too old or do not match the optional author filter. An error after the command message disappears does not prove that a cleanup succeeded. Avoid repeating a large command in a busy channel: new messages may enter the next fetched batch.
Keep cleanup within the Free module’s scope
Moderation is a Free module, so this recent-message cleanup does not require Pro. Free publishes an allowance of one hosted bot and ten custom commands, with hosting logs retained for one day. The Pro comparison is three bots and two hundred custom commands, with thirty days of hosting logs. Purge is a stock module command rather than a custom command you create.
An upgrade does not lift Discord’s bulk-delete age or request limits. The module still uses the same purge implementation on Pro. Follow the Moderation module link for the wider toolset, or Pricing for plan details; neither is a promise to erase old channel history or private conversations.
Frequently asked questions
Who may use purge?
The caller needs Manage Messages. The bot also needs permission to fetch, delete and reply in the target server channel.
Can purge remove messages older than 14 days?
No. This module excludes messages at least 14 days old from its bulk-delete batch.
Is the amount an exact deletion count?
No. Input accepts 1–100, but the current fetch requests one extra message. Small batches can delete one extra; input 100 can fail.
Can it wipe all history or delete DMs?
No. Purge handles a recent batch in the current server channel, not complete history or direct messages.
