Wiki / Core Features / Discord Moderation / Purge a member's messages

Purge a member's messages

Created by Maxime_48 · 5 hours ago · Views: 0

Delete every message one member left on your server, even a member who already left or was banned.

One command does this: /purge-user (staff, deletes for good).


🧹 Delete a member's messages: /purge-user

/purge-user goes through your channels and threads and deletes the messages written by one account. Use it after a spam wave, a raid account, or a member who posted something you want gone everywhere.

  1. Type /purge-user.
  2. In user, give a mention or the member's Discord user ID (17 to 20 digits). To copy the ID, turn on Developer Mode in Discord (User Settings, Advanced), right-click the member, Copy User ID. A member who left or was banned cannot be mentioned any more, so use the ID for them.
  3. Optionally narrow it down with channel, days and reason (see below), then press Enter.
  4. The bot shows what it is about to do, with two buttons: Confirm and Cancel.
  5. Press Confirm. The deletion starts and the message updates as it goes.

Everything the bot says during this is private: only you see it.

The options

Option Required What it does
user yes A mention or a raw user ID (17 to 20 digits).
channel no Only this channel and the threads under it. Without it, every channel of the server is scanned.
days no Only messages from the last N days, from 1 to 5000. Without it, the whole history is scanned.
reason no Up to 512 characters. It is written in your moderation log channel, not sent to the member.

🎯 What it reaches, and what it does not

Read this before you confirm.

It reaches the messages written by that account in text, announcement, voice and stage channels, and in threads (active and archived, forum and media posts included), but only where both you and the bot are allowed to manage messages.

The bot checks your permissions channel by channel, not just your server-wide role. A channel is purged only if:

  • you can see it and hold Manage Messages there, and
  • the bot can see it, read its history and hold Manage Messages there.

If one of you is missing a permission in a channel, that channel is left untouched. The command does not fail: it carries on with the other channels and lists them in the final report.

Two kinds of thread are stricter:

  • Private threads: you also need Manage Threads. Without it, the thread is left alone and not named in the report.
  • Archived threads: the bot needs Manage Threads too. It reopens the thread, deletes the messages, then archives it again. Archived private threads are only looked for when both you and the bot hold Manage Threads on the parent channel.

It does not:

  • ban, kick, mute or warn the member, and it adds nothing to their moderation history. It only deletes messages. If the member is still on the server, use /ban or /mute separately.
  • reach a channel you cannot manage yourself, even if the bot can. This is deliberate: the command never lets you delete what you could not delete by hand.
  • delete messages the member posts after the bot has already scanned that channel.
  • touch other servers or direct messages.
  • name a channel you cannot see. It is left out of the report, so the report cannot tell you it exists.

The bot refuses its own ID: purging it would wipe your log channel history and break the role, ticket, verification and giveaway panels it keeps track of.


⏳ How long it takes, and the report

Discord has no search for bots, so the bot reads each channel's history page by page and picks out the member's messages.

  • Messages younger than 14 days are deleted in groups of up to 100.
  • Messages older than 14 days can only be deleted one by one. On a busy server with a long history, this can take a long time. Narrow it with days or channel when you can.
  • The progress message updates at most every 5 seconds: how many messages are deleted so far, the channel it is in, and how many channels remain.
  • Only one purge can run at a time per server. A second one gets "A purge is already running on this server".

When it finishes, the bot answers with the number of messages deleted, the number of channels scanned and a list by channel. The report can also hold:

  • Not purged (your permissions): channels where you lack a permission.
  • Skipped (bot permissions): channels where the bot lacks one.
  • Failed, the other channels went on: channels that stopped on an error. What was already deleted there stays deleted.
  • a count of messages that could not be deleted, per channel.

A long list is cut short with "… and N more". If nothing was found, you get the same report with 0 messages deleted.

If the purge runs for more than 14 minutes

Discord lets the bot edit its answer for 15 minutes only. About 14 minutes after you typed the command, the bot stops updating the message and sends the final report to you in a direct message instead, with the server name at the bottom. Make sure your DMs from server members are open, or you may miss it. The log channel entries (below) are still written.


⚠️ Confirmation and cancelling

  • The confirmation names the member, says which channels and how many days are covered, and says This cannot be undone.
  • Only you can press the buttons.
  • You have 60 seconds. After that the message says "Confirmation expired: nothing was deleted." and nothing happens.
  • Cancel stops everything: "Cancelled: nothing was deleted."
  • Once you press Confirm, it cannot be cancelled. The buttons disappear and there is no stop command. If the bot restarts in the middle, the purge stops where it was: what was deleted stays deleted, the rest stays in place.

Deleted messages cannot be recovered. The bot does not keep the content of the messages it deletes.


📋 What is logged

If you set a moderation log channel, two entries appear there:

  1. MESSAGE PURGE STARTED, written before the first deletion: the member, the scope, your name and the reason. If the purge is cut short, you still know who ran it and on whom.
  2. MESSAGES PURGED, written at the end: how many messages were deleted and in how many channels, with the same details.

Neither entry contains the text of any message, only counts.


🔑 Who can use it

All of these must be true:

  • the Moderation feature is enabled on the server
  • the person has the Manage Messages permission in Discord. This is the permission that makes the command visible.
  • if you set Allowed moderator roles (slash commands) in the Moderation settings, they also hold one of those roles
  • they hold Manage Messages in every channel they want purged, as explained above (and Manage Threads for private threads)

The bot needs, in each channel it should purge: View Channel, Read Message History and Manage Messages. For archived threads, Manage Threads as well.


💡 Example

A spam account joined, posted invite links in several channels, and was banned two days later.

  1. Copy the account's ID (a banned user cannot be mentioned).
  2. Type /purge-user user:123456789012345678 days:3 reason:invite spam.
  3. The bot asks you to confirm. Press Confirm.
  4. When it ends, the report gives the number of messages deleted, in how many channels, and how many channels were scanned.
  5. A channel listed under Not purged (your permissions) is one where you do not hold Manage Messages, for example a staff-only channel. Another moderator can run the command with channel set to it if needed.

🔧 When something goes wrong

🚨 "Give a user mention or a Discord user ID (17 to 20 digits)"

The user field is not a mention or an ID. Copy the ID again with Developer Mode on. A name or a tag does not work.

🚨 "The Moderation feature is not enabled for this server"

Turn the feature on in the panel, then try again. The message contains the link.

🚨 "This server is not registered in the YAWBDB panel"

The server is not connected to the panel. Connect it first.

🚨 "You do not have a role that is allowed to use moderation commands on this server"

Your server limits moderation commands to certain roles. Ask an admin to add yours under Allowed moderator roles (slash commands), or to empty that list.

🚨 "A purge is already running on this server"

Another purge is in progress. Wait for its report, then run yours.

🚨 "I could not read your permissions on this server, so nothing was deleted"

Discord did not give the bot your permissions. Nothing was deleted. Try again in a moment.

🚨 I cannot see /purge-user in the command list

Discord hides it from anyone without Manage Messages. A server admin can also change who sees it in Server Settings → Integrations → YAWBDB.

🚨 Some messages are still there after the report

Look at the report: a channel under Not purged (your permissions) or Skipped (bot permissions) was left untouched, and a private thread without Manage Threads is skipped as well. Fix the permission and run the command again with channel. Running it again is safe: messages already gone are simply not found.

🚨 I purged the wrong member

It cannot be undone. The messages are gone for good.