How to log deleted messages on Discord
Discord doesn't show what a deleted message said. A logging bot does: it posts each deletion and edit, with the old text, to a channel only your staff can see, along with members joining and leaving. The logging template has those flows drawn. It reacts to server events, so it runs on Buildcord Boost, the $8-a-month plan.
Steps
Make a private log channel
Create a channel such as
logsand allow only your moderators and the bot to see it.Turn on two intents
In the Discord Developer Portal, on your application's Bot page, turn on Message Content Intent to log what messages said and Server Members Intent to log joins and leaves.
Start from the logging template
Open the logging template in Buildcord. It makes a bot with an event flow for each of Member joins, Member leaves, Message edited and Message deleted.
Point it at your channel
In each flow's Send to a channel step, choose your log channel. Change the wording or the embed's color if you like.
Deploy and test
Paste your token and deploy. Send a message from a test account, edit it, then delete it. Both should appear in the log within a second or two.
Good to know
- The bot can only say what a message said if it saw it sent, so messages from before it went live are logged without their text.
- An edit shows the text before as
{message.before}and after as{message.content}. - Add more events the same way: Member banned, Member changes for role and nickname changes, Channel deleted, Role created and Invite created.
- Skip bots with a Member check, so other bots' clean-up doesn't flood the log.
Questions
Can the log say who deleted a message?
No. Discord tells bots which message was deleted and who wrote it, but not who deleted it. Moderator deletions are in your server's audit log.
Can I see messages that were deleted before I added the bot?
No. The bot only knows the text of messages it saw sent while it was running.
Are logged messages stored anywhere else?
Not as the template comes. They are posted to your log channel. Add an Add row step if you want them in a collection too.
More guides
- How to make a Discord bot without coding
- How to build a Discord bot from ChatGPT
- How to set up a ticket system in Discord
- How to give roles automatically in Discord
- How to post in Discord when someone goes live
- How to host a Discord bot 24/7 for free
- How to make custom slash commands in Discord
- How to set up a welcome message in Discord
- How to set up a warning system in Discord
- How to make a Discord reaction role bot
- How to set up auto-moderation on Discord with AI
- How to make a poll in Discord with a bot
- How to set up a starboard on Discord
- How to make a Discord reminder bot
- How to make a Discord birthday bot
- How to make a Discord application form
- How to make a counting channel in Discord
- How to post YouTube uploads to Discord automatically
- How to make an AI FAQ bot for your Discord server