-
-
Save IMcPwn/0c838a6248772c6fea1339ddad503cce to your computer and use it in GitHub Desktop.
// Turn on Developer Mode under User Settings > Appearance > Developer Mode (at the bottom) | |
// Then open the channel you wish to delete all of the messages (could be a DM) and click the three dots on the far right. | |
// Click "Copy ID" and paste that instead of LAST_MESSAGE_ID. | |
// Copy / paste the below script into the JavaScript console. | |
// If you're in a DM you will receive a 403 error for every message the other user sent (you don't have permission to delete their messages). | |
var before = 'LAST_MESSAGE_ID'; | |
clearMessages = function(){ | |
const authToken = document.body.appendChild(document.createElement`iframe`).contentWindow.localStorage.token.replace(/"/g, ""); | |
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 = 500; | |
function delay(duration) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve(), duration); | |
}); | |
} | |
fetch(baseURL + '?before=' + before + '&limit=100', {headers}) | |
.then(resp => resp.json()) | |
.then(messages => { | |
return Promise.all(messages.map((message) => { | |
before = message.id; | |
return delay(clock += interval).then(() => fetch(`${baseURL}/${message.id}`, {headers, method: 'DELETE'})); | |
})); | |
}).then(() => clearMessages()); | |
} | |
clearMessages(); |
@TheOutride I'm getting an "VM324:44 Uncaught (in promise) TypeError: messages.map is not a function
at fetch.then.then.messages (:44:32)" error, do you know what might be causing that
@TheOutride
Yes its working, but no any different from mine (/Altoids1's) except for more error messages, some "completed randomnumber" message loops, and a bit faster progress (maybe just illusion). Thanks for credits anyway. Keep it up, bro.
btw, some other also cant insert code via webversion?
Get "Scam Warning" and nothing happening, - in normal desktop-app everything is still working fine.
I found something much more handy:
- Download AutoHotkey:
https://www.autohotkey.com/ - Save a script with a notepad: Name.ahk
`
^j::
Loop, 100
{
send, {Up}
send, ^a
send, {BS}
send, {Enter}
send, {Enter}
sleep, 500
}
Return
`
3. Go in Disocrd, choose a Channel, start Autohotkey/Script (You have the Icon in tray now)
4. Run the script with ur choosen hotkey (default CTRL + J) (the first letters in script, self explaining)
Now you see how its deleting, without any token sht, without any javascript and console..
No any of this complicated crap is need any more... finaly...
For better handle:
Search ur messages via Discord-Search Funktion, Jump to it, run script, toggle between recent and all for update.
At any time you need to start again (reached the 100 or whatever) - or just increase the value (not tested yet).
If you want to stop (for example choose channel, doing some other: Rightclick on tray-icon and pause scripts.
When you are done, just close the application: Rightclickl on tray-icon and exit.
Source:
https://www.youtube.com/watch?v=7vYQATyqpos
Use it on own risk (for me its working fine)
This works for me 3/3/19
var before = 'LAST_MESSAGE_ID';
clearMessages = function(){
var authToken = 'ENTER_HERE_UR_TOKEN'
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 = 500;function delay(duration) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), duration);
});
}fetch(baseURL + '?before=' + before + '&limit=100', {headers})
.then(resp => resp.json())
.then(messages => {
return Promise.all(messages.map((message) => {
before = message.id;
return delay(clock += interval).then(() => fetch(${baseURL}/${message.id}
, {headers, method: 'DELETE'}));
}));
}).then(() => clearMessages());
}
clearMessages();
To find token: Using F12 > Application > Storage >Discord.app.com > Then look for token, sometimes you have to refresh and it's usually the last Key - copy it quickly
I found something much more handy:
- Download AutoHotkey:
https://www.autohotkey.com/- Save a script with a notepad: Name.ahk
`^j::
Loop, 100
{
send, {Up}
send, ^a
send, {BS}
send, {Enter}
send, {Enter}
sleep, 500
}
Return`
3. Go in Disocrd, choose a Channel, start Autohotkey/Script (You have the Icon in tray now)
4. Run the script with ur choosen hotkey (default CTRL + J) (the first letters in script, self explaining)
Now you see how its deleting, without any token sht, without any javascript and console..
No any of this complicated crap is need any more... finaly...For better handle:
Search ur messages via Discord-Search Funktion, Jump to it, run script, toggle between recent and all for update.
At any time you need to start again (reached the 100 or whatever) - or just increase the value (not tested yet).
If you want to stop (for example choose channel, doing some other: Rightclick on tray-icon and pause scripts.
When you are done, just close the application: Rightclickl on tray-icon and exit.Source:
https://www.youtube.com/watch?v=7vYQATyqposUse it on own risk (for me its working fine)
not working, it doesn't delete anything.
var before = 'LAST_MESSAGE_ID';
clearMessages = function(){
const authToken = "ENTER_TOKEN_HERE";
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 = 500;
function delay(duration) {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), duration);
});
}
fetch(baseURL + '?before=' + before + '&limit=100', {headers})
.then(resp => resp.json())
.then(messages => {
return Promise.all(messages.map((message) => {
before = message.id;
return delay(clock += interval).then(() => fetch(`${baseURL}/${message.id}`, {headers, method: 'DELETE'}));
}));
}).then(() => clearMessages());
}
clearMessages();
This code still works (original code). Just replace id of the last message and token then you're good to go.
Doesn;t work. I still see my messages. even after reloading or logging in again
I found something much more handy:
- Download AutoHotkey:
https://www.autohotkey.com/- Save a script with a notepad: Name.ahk
`^j::
Loop, 100
{
send, {Up}
send, ^a
send, {BS}
send, {Enter}
send, {Enter}
sleep, 500
}
Return`
3. Go in Disocrd, choose a Channel, start Autohotkey/Script (You have the Icon in tray now)
4. Run the script with ur choosen hotkey (default CTRL + J) (the first letters in script, self explaining)
Now you see how its deleting, without any token sht, without any javascript and console..
No any of this complicated crap is need any more... finaly...
For better handle:
Search ur messages via Discord-Search Funktion, Jump to it, run script, toggle between recent and all for update.
At any time you need to start again (reached the 100 or whatever) - or just increase the value (not tested yet).
If you want to stop (for example choose channel, doing some other: Rightclick on tray-icon and pause scripts.
When you are done, just close the application: Rightclickl on tray-icon and exit.
Source:
https://www.youtube.com/watch?v=7vYQATyqpos
Use it on own risk (for me its working fine)not working, it doesn't delete anything.
Tested right now. Its working, you did something wrong.
Have you followed exactly the instructions? Remember you have to save the quotes plaintext as Your-name.ahk
To start you need to open the program via the file, go in channel and pressing CTRL and J same time.
Doesn;t work. I still see my messages. even after reloading or logging in again
Tested mine? Worked still weeks ago, since there I do it with the autohotkey program.
I've been working on another solution for Discord message deletion.
https://github.com/c-edw/discord-delete
So this thing delete EVERYTHING in discord?
Would be a good solution when I creating new Account.
This script used to work for me until a few updates ago.
Uncaught (in promise) TypeError: messages.map is not a function
at fetch.then.then.messages (:20:31)
is the error I started to get recently.
I've been working on another solution for Discord message deletion.
https://github.com/c-edw/discord-delete
Is this legit? I like the idea of it!
https://gist.github.com/z861gz6wb2/fd89c6cf9db9662c68698736d937f0d2
Hey guys, I updated the Discord "mass message deletion browser script" with LOTS of improvements and bug fixes. I rewrote most parts of the script. Now you don't even need to fill in your auth token, user id, channel id. The message id part is optional. My script fetches all the needed information for you so all you gotta do is copy and paste. It works anywhere, in channels and DMs. It even lets you know when it's finished deleting all the messages, so just chill until you get the alert. I made the alert tell you how many messages it deleted too so lots of good stuff. Feel free to look at the code and tweak it anyway you like. You can even turn it into a bookmark for easy launching, just use the "javascript:" prefix followed by the code (run my script through a JS minifier first) then put it in the URL box when adding it as a bookmark.
EDIT: People are reporting that this script fails to grab the auth token in chromium browsers like Opera and Brave. However I tested it in Chrome Canary and it worked. So if you don't want to use Chrome, you can fill in your token manually.
https://gist.github.com/z861gz6wb2/fd89c6cf9db9662c68698736d937f0d2
Hey guys, I updated the Discord "mass message deletion browser script" with LOTS of improvements and bug fixes. I rewrote most parts of the script. Now you don't even need to fill in your auth token, user id, channel id. The message id part is optional. My script fetches all the needed information for you so all you gotta do is copy and paste. It works anywhere, in channels and DMs. It even lets you know when it's finished deleting all the messages, so just chill until you get the alert. I made the alert tell you how many messages it deleted too so lots of good stuff. Feel free to look at the code and tweak it anyway you like. You can even turn it into a bookmark for easy launching, just use the "javascript:" prefix followed by the code (run my script through a JS minifier first) then put it in the URL box when adding it as a bookmark.
I replied to your code that I'm getting this error that it cannot find the IDs:
"VM369:20 Uncaught TypeError: Cannot read property 'replace' of undefined
at :20:62
at :84:3"
EDIT:
I can confirm it works if you do it manually, as the Authtoken just appears for a brief 1 sec when you load the page and the script cannot find it afterwards when it runs.
Manually:
- Simply use the original method to catch it (I used screenshot and typed it in manually, cause I'm too slow to copy+paste or it doesn't work?!).
- Paste/type it here <<const authToken = frame.contentWindow.localStorage.token.replace(/"/g, "");>>, meaning you replace <<frame.contentWindow.localStorage.token.replace(/"/g, "")>> with <<"YOUR_AUTHTOKEN">>
(I used <<>> to quote, so remove those and don't forget to add the "") - Thank the guys that helped with the code! <3
UPDATE: 2019-APRIL
I wrote a mass delete script properly, it logs the messages being deleted along with a progress on a popup.
it also gives you an estimated time!
https://gist.github.com/victornpb/135f5b346dea4decfc8f63ad7d9cc182
There another solution , using android mobile application to delete the messages , it work , i tested it
https://play.google.com/store/apps/details?id=com.mlika.discorddelete.free
Please be EXTREMELY careful of downloading applications. Make sure you trust them with the permissions you give them.
Code currently working found here: https://github.com/TheOutride/Discord-Deleting-DM
Doesn't work anymore.
Doesn't work anymore.
EDITED: WORKING AS JAN-2020
Take a look at this https://github.com/victornpb/deleteDiscordMessages
full disclaimer, I'm the author.
Doesn't work anymore.
WORKING AS AUG-2019
Take a look at this https://github.com/victornpb/deleteDiscordMessages
full disclaimer, I'm the author.
Works! thank you! - just wish I could delete all messages in all channels :P
Doesn't work anymore.
WORKING AS AUG-2019
Take a look at this https://github.com/victornpb/deleteDiscordMessages
full disclaimer, I'm the author.
didnt work man
WORKING AS AUG-2019
Take a look at this https://github.com/victornpb/deleteDiscordMessages
full disclaimer, I'm the author.didnt work man
It is working as JAN-2020
Works for me still on Chromium, but not firefox. Works on most channels, that is. For one channel I do get
authorID="ommited" guildId="618621882110967809" channelId="663328918719168514" afterMessageId="" beforeMessageId="" hasLink=false hasFile=false
Error searching messages, API responded with status 403!
{"message":"Missing Access","code":50001}
Despite being able to hand delete messages in that channel aslo
I was able to delete only my messages from the private text message. How can I delete the other person message. Please advice
I found this repo pretty useful. Its fast and easy to use.
Senior Software Developer here. Nice work, thanks for saving me some time!
Status on 3/19/2021: WORKING
https://gist.github.com/jsoctocat/586feb9e530e61e6f499f7b7773b4df3
Hey guys sorry about disappearing. Been busy. Apparently, like an absolute noob, I left my auth token on the original code. Deleted that entire repository and made a new one.
https://github.com/TheOutride/Discord-Deleting-DM/blob/master/Delete-Messages.js
Please drop any issues over there. Someone had made a pull request to update the ReadMe. I didn't have time to update it before deleting it.
@Altoids1 No problem. Thanks for the code really, I didn't do a whole lot beyond looping it