Last active
March 31, 2022 11:46
-
-
Save B3none/d8e9bab61a851cbe9fbe99788c3e4ab8 to your computer and use it in GitHub Desktop.
Here's a cheeky mass DM delete for Discord.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I use this?
Google Chrome
.Inspect
.Network
.science
.TOKEN_HERE
with the token that you just copied.USERNAME_HERE
with your discord display name. (NOT YOUR EMAIL)Console
on the right panel that you opened on discord.