Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Here's a cheeky mass DM delete for Discord.
let deleteMessages = (username, authToken, before = false) => {
const channel = window.location.href.split('/').pop();
const baseURL = `https://discordapp.com/api/channels/${channel}/messages`;
const headers = {
"Authorization": authToken
};
let clock = 0;
let interval = 358;
let delay = (duration) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), duration);
});
};
let nextBefore = '';
fetch(baseURL + '?limit=100' + (!!before ? ('&before=' + before) : ''), {
headers
})
.then(resp => resp.json())
.then(messages => {
return Promise.all(messages.map((message) => {
if (messages.indexOf(message) === 99) {
nextBefore = message.id
}
if (message.author.username.toLowerCase() === username.toLowerCase() && typeof message.call !== 'object') {
return delay(clock += interval).then(() => fetch(`${baseURL}/${message.id}`, {
headers,
method: 'DELETE'
}));
}
}));
}).then(() => {
if (nextBefore) {
deleteMessages(username, authToken, nextBefore)
}
});
};
deleteMessages("USERNAME_HERE", "TOKEN_HERE");
@b3none

This comment has been minimized.

Copy link
Owner Author

commented Oct 9, 2018

How do I use this?

  1. Open Discord in Google Chrome.
  2. Login to Discord if you aren't already.
  3. Open direct messages with anyone.
  4. Right click any message text and click Inspect.
  5. On the tab that opens on the right hit Network.
  6. In the filter box type science.
  7. Click on one of the results that will show up. (If you don't see any results refresh the page and repeat from step 6)
  8. Click on Headers and at the bottom you should see Request Payload.
  9. Copy the token.
  10. Replace TOKEN_HERE with the token that you just copied.
  11. Replace USERNAME_HERE with your discord display name. (NOT YOUR EMAIL)
  12. Click Console on the right panel that you opened on discord.
  13. Paste in the copied code with the replaced text and hit enter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.