Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord API changes have partially broken message deletion #21

Closed
larryqiann opened this issue Nov 23, 2019 · 17 comments
Closed

Discord API changes have partially broken message deletion #21

larryqiann opened this issue Nov 23, 2019 · 17 comments
Assignees
Labels
bug Something isn't working

Comments

@larryqiann
Copy link

It looks like many messages are being left behind when running the Go version - I have run it manually several times and each time it finishes with a significant number of messages remaining in threads. I know the tool is hitting them because newer messages are deleted, but there are a lot remaining. Is this an expected behaviour? The Python version worked correctly last I tried it,

@cedws
Copy link
Owner

cedws commented Nov 23, 2019

Is this an expected behaviour?

It isn't, it should delete everything it can find on the first run. However, I have some ideas why this might be happening.

Are you using the latest release? And do you see any errors in the output? (pass -v if you aren't doing so already)

@larryqiann
Copy link
Author

larryqiann commented Nov 23, 2019

INFO[0048] Deleting message 647243810 from channel 647149098
DEBU[0048] DELETE https://discordapp.com/api/v6/channels/647**9098/messages/647**143810
DEBU[0048] Server returned status No Content
DEBU[0048] Skipping context message
DEBU[0048] Skipping context message
INFO[0048] Deleting message 6474855 from channel 647149098
DEBU[0048] DELETE https://discordapp.com/api/v6/channels/6471***98/messages/6472***855
DEBU[0048] Server returned status No Content
DEBU[0048] Skipping context message
DEBU[0048] Skipping context message
INFO[0048] Deleting message 64703 from channel 64719098
DEBU[0048] DELETE https://discordapp.com/api/v6/channels/64718***9098/messages/6472***4803
DEBU[0048] Server returned status Too Many Requests
INFO[0048] Server asked us to sleep for 518 milliseconds
DEBU[0049] DELETE https://discordapp.com/api/v6/channels/6471***9098/messages/647***803
DEBU[0049] Server returned status No Content
DEBU[0049] Skipping context message
DEBU[0049] Skipping context message
INFO[0049] Deleting message 647888 from channel 64775
DEBU[0049] DELETE https://discordapp.com/api/v6/channels/647***875/messages/647***888
DEBU[0049] Server returned status No Content
DEBU[0049] GET https://discordapp.com/api/v6/guilds/643***24/messages/search?author_id=247***0945&include_nsfw=true&offset=0&limit=25
DEBU[0049] Server returned status OK
INFO[0049] No more messages to delete for guild '*********'
larryqian@Larrys-MacBook-Pro Downloads %

This is what it looks like when it ends. No other errors are raised.
I do get "No more messages to delete for $server" messages though.

@cedws
Copy link
Owner

cedws commented Nov 24, 2019

Everything in the log seems normal. There's probably a bug with the message querying algorithm. Question: in the groups that it fails to clear all messages from, are there a lot of calls? Discord actually considers these messages but they have a different numeric type, so the code has to increment an offset when it finds these.

@larryqiann
Copy link
Author

The failures are fairly well distributed, and are equally present in servers lacking a voice channel/calls altogether.

@cedws
Copy link
Owner

cedws commented Nov 24, 2019

I'm able to reproduce this issue... it's not looking good. I think Discord have broken the way the program finds messages. Some queries are returning zero results.

Still looking for a solution.

@cedws cedws added the bug Something isn't working label Nov 24, 2019
@cedws cedws self-assigned this Nov 24, 2019
@larryqiann
Copy link
Author

Interestingly enough recently the only other Discord deletion app on GitHub also died in a similar way, with errors related to "Got an empty page from the server".

I noticed that on the webUI doing a search in a server for messages you sent sometimes didn't return results either. Clicking "next page" several times always returned results, and seems to just increment the offset by 25 each time. It looks like the search endpoint they are using is /guilds/55...76/messages/66...78/?author....but the official deletion api uses /channels.

@cedws
Copy link
Owner

cedws commented Nov 24, 2019

Yep, their API is completely broken. It's returning empty pages and 500s all the time now. I hope this won't be a problem forever, because it makes this tool unusable. There's no way around it other than brute-force searching, which is only really practical for DMs.

I've just committed c61c770 which might help a bit, but really, the issue is on Discord's side. Not much that I can do. I will leave this issue open and hopefully we'll see them resolve this within the next few weeks.

Thanks for the report as always.

@larryqiann
Copy link
Author

It looks like this new commit has resolved the problem and it was able to clear out everything it missed. Thanks!

With that said the way search works is definitely broken on their end. It still says that there are messages remaining and 20 pages, even though none of them are populated in the official app. Maybe it takes them a while to update that index.

@cedws cedws changed the title Go version seems to miss messages Discord API changes have partially broken message deletion Nov 25, 2019
@blawar
Copy link

blawar commented Nov 26, 2019

I fixed this issue and posted a working script to highlight the fix.

The issue is that discord api is returning a positive number of results, but then the messages array is empty. This happens when you delete messages, however discord isnt updating its internal database properly and causes empty messages to be returned that must be skipped.

The solution is to first iterate to get all of the posts, and store them in your own array, then go back and run delete on those message's.

https://github.com/blawar/discordnuke/blob/master/discordnuke.js

@cedws
Copy link
Owner

cedws commented Nov 26, 2019

Thanks, but the solution seems a bit over the top. All you need to do is increment the offset when you find an empty page. This was done in c61c770.

@zyrodos
Copy link

zyrodos commented Dec 9, 2019

hey @cedws i'm getting an error saying level=fatal msg="Error fetching messages for channel: Status code Not Found is unhandled" now, any idea how to get around this?

@cedws
Copy link
Owner

cedws commented Dec 9, 2019

@zyrodos Happens for me too. It looks like another API update has broken the tool. I'll get back to you when there's a fix.

@cedws
Copy link
Owner

cedws commented Dec 9, 2019

What on earth... search doesn't work in the client either. I think their API is outright broken. Try doing a message search in Discord. Do you see Uh... can you try searching again??

@zyrodos
Copy link

zyrodos commented Dec 9, 2019

I am getting the same message when I try to search, yes. Interesting. @cedws

@zyrodos
Copy link

zyrodos commented Dec 10, 2019

I just ran it a few times, and it only removed things from certain channels. It did not remove any DMs.

@cedws
Copy link
Owner

cedws commented Dec 10, 2019

Yeah apparently this is a known ongoing issue. It may be a week or so before the results are fixed.

@cedws
Copy link
Owner

cedws commented Dec 13, 2019

Just pushed release 1.1.5. Discord's backend appears to be fixed, and the API behaviour has reverted to how it was before 1.1.4.

Please upgrade to this release and let me know if you have any problems.

@cedws cedws closed this as completed Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants