Skip to content

Instantly share code, notes, and snippets.

@B3none
Last active March 31, 2022 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save B3none/d8e9bab61a851cbe9fbe99788c3e4ab8 to your computer and use it in GitHub Desktop.
Save B3none/d8e9bab61a851cbe9fbe99788c3e4ab8 to your computer and use it in GitHub Desktop.
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 = 400;
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
Copy link
Author

B3none 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