Skip to content

Instantly share code, notes, and snippets.

@victornpb
Last active February 23, 2024 03:14
Star You must be signed in to star a gist
Save victornpb/135f5b346dea4decfc8f63ad7d9cc182 to your computer and use it in GitHub Desktop.
Delete all your messages from DM or Channel in Discord

Delete all messages in a Discord channel or DM


👉 UPDATE: This gist moved to https://github.com/victornpb/undiscord


  1. Open Discord in a browser like Chrome or Firefox;

  2. Open DevTools pressing F12 or ⌘ command+option+J;

  3. Copy the deleteDiscordMessages.js script and paste it in the Console, then press ENTER;

  4. A window will be opened, fill the variables and click the START button.

Variables

authToken

  1. Open the dev tools (F12), open the Network tab. (You should clear all requests for better readability if you see some.)
  2. Delete one message manually. In the request log, you will see a request with a DELETE method.
  3. Click on the request to open the details, and on the Headers tab, copy the 'authorization' token. It's a long text > with dots like MTX5MzQ1MjAyMjU0NjA2MzM2.ROFLMAO.UvqZqBMXLpDuOY3Z456J3JRIfbk.

authorId

  • Right click your avatar in a message you sent in the chat, Copy ID

    NOT THE MESSAGE THE AVATAR.
    (You cannot delete the other's person messages a in DM channel, you will get Error 403)

channelId

  • For public channels: Right click a channel, Copy ID
  • For a DM/Direct messages: copy the number after /@me/ in the URL)

firstMessageId

  • Delete messages after one message:
    Right click a message, Copy ID
  • Delete since the begining of a channel:
    Leave this variable empty "".


DeveloperMode

If the Copy ID menu doesn't show up when right clicking:

  • Enable developer mode in discord Go to user Settings > Appearance in discord and enable Developer mode.

DO NOT SHARE YOUR authToken!

Sharing your authToken on the internet will give full access to your account! There are bots gathering credentials all over the internet. If you post your token by accident, LOGOUT from discord on that same browser you got that token imediately. Changing your password will make sure that you get logged out of every device. I advice that you turn on 2FA afterwards.

If you are unsure do not share screenshots, or copy paste logs on the internet.


DISCLAIMER: THE SOFTWARE AND ALL INFORMATION HERE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

By using any code or information provided here you are agreeing to all parts of the above Disclaimer.

Last tested: 2019-AUG-21

/*
This file is now hosted here:
https://github.com/victornpb/undiscord
*/
@Chipiron95
Copy link

Hey, what can i do with?:

Started at 8/19/2019, 10:47:37 AM
channelId=544122824873476126 authorId=527227515706540053 firstMessageId=
---- You can abort by setting STOP=1 on the console ----
API respondend with non OK status! {"code":0,"message":"401: Unauthorized"}

@victornpb
Copy link
Author

victornpb commented Aug 21, 2019

OK, I finally put some time in handling system messages. It seems to be working now, but I'm limited to generating dummy messages to delete. Please let me know if you find any issue.

Thanks @JoeCow for the contribution. In the end I handled things differently, It should not leave messages behind anymore.

Also I made it simpler to use I implemented a minimal user interface, and I can fill the author and channel you're on automatically, so you only need to provide the authToken. That made the code quite bigger tho. But I don't want to make the code cryptic just to make it short because I want it to still be readable, so pleople can trust it before running it.
Screen Shot 2019-08-21 at 1 47 13 AM

EDIT:

@victornpb
Copy link
Author

victornpb commented Aug 21, 2019

I'm migrating this Gist to a GitHub Repository. It will be easier for me to make changes and answer issues and questions individually using the the issues tab.

Please post your comments, questions, issues, ideas HERE


GIST MOVED TO

https://github.com/victornpb/undiscord

@SKN1
Copy link

SKN1 commented Dec 26, 2019

Error deleting message, API responded with status 403! {"message":"Cannot execute action on a DM channel","code":50003}

how fix it?

@phrohdoh
Copy link

@SKN1 the comment just before yours tells you to ask questions on the GitHub repo, not this gist.

@DYR0S
Copy link

DYR0S commented Mar 26, 2020

Can I have your discord? I need you with something

@Connor200024
Copy link

Isn't this just against discord TOS? ;) My suggestion it's pointless and awful to use! :D

Copy link

ghost commented Jul 12, 2020

Hi, I'm having some trouble using this and wanted to ask if it works for messages in banned servers? I'm filling in all the details, with the exception of GuildID because I can't get that (I think it's the server), but I'm just getting 404 errors.

@TosBreaker
Copy link

Anyone wondering. yes. This is a TOS breaker. It WILL get you banned. I do not know if they will delete your account. But this is self botting. Your account will.100% be banned, as I found out.

If discord implemented a function to delete messages, however, it would resolve this issue. Seems they wont though.

I managed to delete a few thousand messages however, before getting banned. Say about in the region of 10,000.

Then I ended up getting banned.

@sc0rp10n-py
Copy link

This works fine when deleting messages from a public channel, but throws a 404 error for DMs. Tried with several different people. Can you see if you can reproduce that problem?

for DM
use guild id :@me
and channel id: text after @me/ in url

@sc0rp10n-py
Copy link

Same...404 error

for DM
use guild id :@me
and channel id: text after @me/ in url

@CyberpunkVx-1729
Copy link

CyberpunkVx-1729 commented Jul 28, 2021

Thanks #victornpb
I owe you one !

@bipstick
Copy link

bipstick commented Aug 5, 2021

it worked fine and delted like 55 messages but then i get smth that looks like this :
Screenshot_1

i didnt change any info or settings it just stopped. suggestions?>

@hh4yl3yy
Copy link

its not letting me do anything and ive entered all the ids and stuff

@hh4yl3yy
Copy link

please help me nothings working

@fourteen-1
Copy link

how do i find the auth token in firefox? "get" isn't doing anything and i cant manually find it in console

@To-Code-Or-Not-To-Code
Copy link

404 message on public channel. filled everything in. Doesn't work. Exit code `0```

@victornpb
Copy link
Author

victornpb commented Apr 29, 2022


DISCUSSION MOVED TO

👉 https://github.com/victornpb/undiscord/discussions


⛔️ DO NOT USE THIS COMMENT SECTION, YOU WILL NOT BE ANSWERED HERE!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment