The message log
The message log keeps a record of edited and deleted messages, so staff can see what someone wrote after they change or remove it. It needs the messagelog module and the messagelog feature (configuration).
How it works
- In every server with a message-log channel, the bot keeps a copy of each message as it's posted, and downloads its pictures, videos and files, because Discord deletes them with the message.
- When a message is edited, the bot posts a Message edited post in the channel, with what changed, and keeps the earlier text.
- When a message is deleted, it posts a Message deleted post with the text, and uploads the message's files with it. The post says who deleted it (see Who deleted a message).
- The panel's Message log page lists the same messages, for staff with the Message logs permission (by default, Discord's Manage Messages).
Messages from bots and webhooks, and messages in the message-log channel itself, aren't logged.
Who deleted a message
Discord doesn't say who deleted a message, but its audit log does when someone deletes another person's message. So the bot reads the audit log after each deletion, and the post and the panel say one of:
- a moderator (their mention and name), when the audit log has an entry for it;
- the bot's name (auto-mod or clean-up), when the bot deleted it itself;
- The author, when there's no entry: deleting your own message leaves none;
- Unknown, when the bot can't read the audit log. Give it View Audit Log; Network status lists it as missing while the message log is on.
Deleting many messages at once (a purge by a moderator or another bot) shows who did it on the Messages deleted post, and on each message. For the bot's own /purge, that's the moderator who ran it, not the bot.
It's a good guess rather than a certainty, in two cases:
- Discord can be slow to write the entry. The bot looks twice, a second and a half apart; an entry that appears later than that means the deletion is put down to the author.
- Discord merges a moderator's deletions of one person's messages in one channel within a few minutes into one entry, and the bot follows the count on it. Just after the bot restarts, it doesn't know an entry's earlier count, so a moderator's deletion merged into an entry from before the restart is put down to the author.
Where files are kept
Files live in Discord, not on your server. The bot's own copy of each file is short-lived: 48 hours by default (messagelog.media_hours). When a message is deleted, its files go up with the Message deleted post, and the bot's copy is removed straight away; the post in Discord is then the only copy. Files someone takes off a message by editing it go up with the edit's post the same way. A message that was only edited still has its files on the message itself in Discord, so the bot's copy just expires.
In the panel, each file is shown as:
| Shown as | Meaning |
|---|---|
| A chip: ๐ผ Image, ๐ Video or ๐ File | The file is in the message-log post. Clicking it opens that post in Discord (you need to be able to see the channel). |
| The picture or video itself, with "Bot's copy until โฆ" | The bot's short-lived copy, while it lasts |
| the message-log post holding it was deleted | The post was deleted, by the bot's clean-up or by hand, so the file is gone. The text stays. |
| not kept, or a reason such as too large | The file wasn't saved: it was over messagelog.max_file_mb or the server's upload limit, or the message was deleted after the bot's copy had expired |
The text of edited and deleted messages, with every earlier version, is kept for good in the database. It's small, and it's what search uses. Unchanged messages are kept for 7 days (messagelog.cache_days) and then forgotten.
Setting it up
- Make sure the bot has Manage Roles, Manage Messages, Attach Files, Read Message History and Manage Threads in the server. The invite link in Discord setup includes them.
- Create a channel for it, such as
#message-log. Or skip this and the next step: Create #message-log in Settings โ Servers (or Create log channels for me on Your servers, or the server menu at the top of the page) makes a private one and chooses it. - Choose it, with
/setup messagelog channel:#message-log, in Settings โ Servers โ Message log, or in the Log channels step of first-run setup. - The bot locks the channel (below). Check the server is green on Network status.
Do this in every server you want logged. A server without a message-log channel doesn't keep messages at all. A message-log channel that's missing or that the bot can't post in turns the server red on Network status; the bot keeps recording text, but files can't be kept.
The locked channel
Message-log posts hold the only copy of deleted messages' files, so the bot locks the channel when it's chosen:
| Who | Can see and read | Can post, react, start threads |
|---|---|---|
@everyone |
No | No |
| Staff who can see the message log (Discord's Manage Messages, or the Message logs permission if the server uses role permissions) | Yes | No, unless Staff can post is on |
| The bot | Yes, and attach files, embed links and manage messages | Yes |
| Administrators | Yes: Discord always lets them do everything | They can, but shouldn't: Remove other posts removes their posts too |
Setting these permissions needs Manage Roles. If the bot can't, Network status says what's wrong.
Changes are noticed. If someone edits the channel's permissions in Discord so they no longer match, Network status turns the server red and says what's different. Admins click Lock again, there or in Settings โ Servers, to put them back.
Settings
Each server has these, in Settings โ Servers โ Message log:
| Setting | Default | What it does |
|---|---|---|
| Staff can post | Off | Lets the staff roles above post in the channel. |
| Remove other posts | On | Removes anything posted in the channel that the bot didn't post (below). |
| Delete posts after [N] days | 0 (keep them all) | Deletes the bot's own old posts (below). 1โ365. |
Clean-up of other people's posts
With Remove other posts on, the bot deletes every message in the channel that it didn't post itself, administrators' messages included, and threads people start there. With Staff can post on, staff posts are left alone.
This is clean-up, not moderation. Those messages aren't copied, aren't logged as deleted messages, and aren't posted anywhere. Each removal is noted in the audit log under the person who posted, so a pattern can be spotted.
Don't delete the bot's posts by hand. For deleted messages, they hold the only copy of the files. If one is deleted by anyone but the bot, the bot notes it in the audit log (with who did it, if Discord's audit log says), and the panel marks its files as gone.
Deleting old posts automatically
A server can have the bot delete its own message-log posts once they're old: Delete posts after [N] days in Settings โ Servers โ Message log, or messagelog_delete_days with PATCH /api/v1/servers/{id} (API). It's off by default.
- The text stays in the panel. Only the posts, and the files in them, are deleted. The panel then shows the files as deleted, with the date.
- Kept posts are never deleted automatically: posts marked Keep, and posts whose message is on a timeline. Unkeep, or taking the message off every timeline, makes the post due again.
- It runs every hour. Discord deletes up to 100 messages at once only while they're under 14 days old, so newer posts go in bulk and older ones one by one, about 60 an hour per server. A long backlog is worked through over several hours.
- It asks first. Turning it on, or making N shorter, says how many existing posts would be deleted straight away and asks you to confirm. (The API doesn't ask.)
- It only deletes posts the bot recorded. Every post the bot makes in the channel is recorded, so it can never delete something it didn't make. Posts made by older versions of the bot weren't recorded: Include older posts looks through the channel's history (up to 20,000 messages, a page every two seconds) for the bot's own posts and records them.
- These deletions are the bot's own clean-up. They're never logged as deleted messages, and each run adds one line per server to the audit log (category Message log).
Using the Message log page
The page lists edited and deleted messages, newest first, for the servers your roles allow. Filter by server (your current server by default), by edited or deleted, and by person (which includes their linked accounts).
- Edits show what changed: removed words struck through in red, added words green, for every edit. "Text before this edit" shows the full earlier text.
- Show surrounding messages lists the saved messages just before and after in the same channel, with this one highlighted. Open in Discord goes to the message, or the channel for a deleted one. Ordinary messages are only kept for 7 days, so around older ones you may see only other edited or deleted messages.
- Each row says what happens to its post: deleted in 3 days, kept, or when it was deleted.
Keep
Keep on a row means its message-log posts are never deleted automatically. Unkeep undoes it. It needs Message logs, and both are recorded in the audit log.
Add to timeline
Edited and deleted messages never appear on someone's timeline by themselves, because there would be too many. To use one as evidence, add it:
- On the person's page, click Add messages on the timeline. The Message log opens filtered to that person and their linked accounts. (Or open the Message log yourself.)
- Tick the messages that matter, or Select all on this page.
- Click Add to timeline. Each message goes on its author's timeline, so ticking messages from several people puts each on the right person's.
- If you started from a timeline, you're taken back to it, with the new entries highlighted.
An added message shows its text, edits, file chips, server and channel, and who added it and when. It's the same for every staff member who can see that server. Messages already on a timeline are marked On the timeline, so nobody adds them twice. If a message's post was already deleted, the text is still added, and the page says the files are gone.
Remove from timeline, on the entry, takes it off the timeline again; the message stays in the Message log. Adding and removing need Message logs, and both are recorded in the audit log. Programs can do the same with POST /api/v1/people/{identity}/timeline and DELETE โฆ/timeline/{entry}, with the messages:write scope (API).
Privacy
The bot stores what people write, and their files for 48 hours, in servers with a message-log channel. Tell your community, for example in your rules, and keep the channel and the panel's Message log to staff who need them. See Privacy and data.
Upgrading from older versions
Older versions kept deleted and edited messages' files on your server for good. Those stay until an admin clicks Move to Discord in Settings โ Servers, which posts each deleted message's files in the message-log channel (one post every two seconds) and removes the bot's copies. See Upgrading from v1.