An open API service indexing awesome lists of open source software.

https://github.com/5ht2/discord-mass-delete

A lightweight way to mass delete old messages
https://github.com/5ht2/discord-mass-delete

Last synced: 4 months ago
JSON representation

A lightweight way to mass delete old messages

Awesome Lists containing this project

README

          

# discord-mass-delete

A quick tool to retroactively delete all messages (or filter to specific channels / guilds), extracted from your Discord data request, or
from search results.

Discord has now fixed their GDPR violations (which I reported to them) since
the [2022/11/10 GDPR fine](https://edpb.europa.eu/news/national-news/2023/french-sa-fines-discord-eur-800000_en).


Old disclaimer about Discord data requests.

**DISCLAIMER:** It wasn't until recently that I discovered that Discord has decided to not include messages from servers you are not
currently in, inside your Discord data request. This contradicts what
their [support article](https://support.discord.com/hc/en-us/articles/360004957991) says and is likely a GDPR violation, given your messages
still exist and are accessible when you leave a server.

The data request, however, still does include all DMs that you have sent a message in or opened, as far as I can tell. I have an opened
ticket (#17970549) in a special channel I was given specifically for these issues, but I have not been given any response since 2021/11/05,
after noting that it was likely a GDPR violation.

Discord has **ignored** further requests to contact them about this matter and has not fixed this issue. This will likely continue to be an
issue until somebody makes an official GDPR complaint.

## Usage

```bash
git clone git@github.com:5HT2/discord-mass-delete.git
cd discord-mass-delete
make
./mass-delete -h # Run the program with help arguments
```

## Running

1. Download your Discord data backup. You can get this by going to Discord Settings > Privacy & safety > Request all of my data
2. Extract the data somewhere. Doesn't matter.
3. Follow the above [usage](#Usage) instructions and run the program from anywhere.
4. Follow the interactive instructions. You can use the `-dir $DISCORD_DIR -dirconfirm` args with `DISCORD_DIR` set to a path to skip the
prompts.
The `-bottoken` arg is the only required argument. `-channels` is a comma separated list of channel IDs.

Example:

```bash
./mass-delete -dirconfirm -dir "$DISCORD_DIR" -channels "$DISCORD_CHANNELS" -bottoken "$DISCORD_BOT_TOKEN"
```

## `.env`

You can also use a `.env` file for flags. Use the following format:

```dotenv
DISCORD_BOT_TOKEN="YOUR BOT TOKEN GOES HERE"
DISCORD_DIR="/path/to/package/messages"
DISCORD_CHANNELS="some_numbers,other_numbers"
DISCORD_GUILDS="some_guild_id"
DISCORD_AUTHORS="some_other_numbers,more_numbers"
```

#### Filtering

There are two possible filter flags: `-channels` and `-guilds`. Both are comma separated lists of IDs. There is also a `-authors` flag for
using search results.

The channels filter takes precedence over guilds.
For example, if you specify a channels filter and a channel is not found in the list, it will be skipped.
If you specify a guilds filter and a channel is not inside one of the specified guilds, it will also be skipped, regardless of the channel
setting.

It is not necessary to use both options if you want to select specific channels inside a guild, as supplying the channels is good enough.

#### Search results

You can also use the search results to delete from, instead of a Discord data request.

1. To do so, open the Chrome Dev Tools with Ctrl Shift I, go to the network tab.
2. Now, make a search, and click through all the pages you would like to use.
3. Open a new Dev Tools window for your existing Dev Tools window with Ctrl Shift I (yes, debug inception).
4. Run the following in the console tab (taken from [StackOverflow](https://stackoverflow.com/a/57782978), works on Chrome 111 or newer):

```javascript
await (async () => {
const getContent = r => r.url() && !r.url().startsWith('data:') && r.contentData();
const nodes = UI.panels.network.networkLogView.dataGrid.rootNode().flatChildren();
const requests = nodes.map(n => n.request());
const contents = await Promise.all(requests.map(getContent));
return contents.map((data, i) => {
const r = requests[i];
const url = r.url();
const body = data?.content;
const content = !data ? url :
r.contentType().isTextType() ? data :
typeof body !== 'string' ? body :
`data:${r.mimeType}${data.encoded ? ';base64' : ''},${body}`;
return { url, content };
});
})();
```

5. Right-click the given result, and select `Copy object`.
6. Paste this to a new `.json` file in the directory that you give the mass delete program.

Run example:

```bash
./mass-delete -dirconfirm -dir "$DISCORD_DIR" -usesearch -authors "$DISCORD_AUTHORS"
```

#### Using a user account instead of a bot account

This program respects Discord's rate limits, so while it *is* against Discord TOS, you can't really get banned for using it (use user tokens
at your own risk, I am not liable).

The first step is required for it to work.
Everything afterward is only something you should do if you are paranoid about your account getting banned.

- Use `-usertoken` instead of `-bottoken`, or `DISCORD_USER_TOKEN` instead of `DISCORD_BOT_TOKEN`.
- Add the regular headers that you would get from deleting a message.
- Press Ctrl Shift I
- Go to the Network tab
- Delete a message
- Hit the last request (usually status 204, make sure the Request Method is `DELETE`)
- Go to Headers
- Scroll down to Request Headers
- Add a line that looks like `req.Header.Set("header name", "request value")`, for each header
- Now you can follow the [Usage](#Usage) instructions. Use your user token with the `-bottoken` arg.