Skip to content

Instantly share code, notes, and snippets.

@rgson
Created November 23, 2018 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rgson/7caf02ad45dbaca3dfa57f205fad81fe to your computer and use it in GitHub Desktop.
Save rgson/7caf02ad45dbaca3dfa57f205fad81fe to your computer and use it in GitHub Desktop.
Delete Discord messages

Discord Eraser

Erases all of your messages in a DM conversation.

Usage

  1. Open Chrome Dev Tools > Network.
  2. Go to https://discordapp.com.
  3. Find some request with the Authorization request header.
  4. Place the header's value in the Authorization variable in eraser.js.
  5. Navigate to the DM conversation in the browser window.
  6. Paste the content of eraser.js into Chrome Dev Tools > Console.
  7. Wait.
(async function() {
const Authorization = 'your-token';
const GET = { headers: { Authorization }, method: 'GET' };
const DELETE = { headers: { Authorization }, method: 'DELETE'};
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const me = await fetch('/api/v6/users/@me', GET)
.then(r => r.json())
.then(d => d.id);
const url = window.location.pathname.replace(/^.+\//, '/api/v6/channels/')
let msgs = await fetch(`${url}/messages?limit=1`, GET).then(r => r.json());
while (msgs.length > 0) {
const ids = msgs.filter(m => m.author.id == me).map(m => m.id);
for (let i = 0; i < ids.length; i++) {
console.log('Deleting message', ids[i]);
const r = await fetch(`${url}/messages/${ids[i]}`, DELETE);
if (r.status === 429) {
await r.json().then(r => sleep(r.retry_after))
i--;
}
}
msgs = await fetch(
`${url}/messages?limit=100&before=${msgs[msgs.length-1].id}`, GET)
.then(r => r.json());
}
console.log('Done');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment