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

refactor(actions): safer getChannel calls #10434

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

didinele
Copy link
Member

@didinele didinele commented Aug 7, 2024

Please describe the changes this PR makes and why it should be merged:
Fixes #10393 and also does a little spring cleaning on areas that could have also been dangerous in the same way.

The gist of #10393 was that it was especially happening when a message sent unarchived a thread, and yet it only sometimes caused the error. It seems that sometimes, Discord was sending the MESSAGE_CREATE payload before the THREAD_UPDATE. The latter normally comes first and populates our cache, which yields to the subsequent getChannel caused by the MESSAGE_CREATE to return from cache.

In cases when the opposite was happening, before #10278 we were unable to resolve the channel type and would simply skip it, not adding it to cache at all (and also skipping the messageCreate) as a result. This is a fundamental flaw of how those partials work, and should be addressed with either the next major, or the library's rewrite. There is no easy way to otherwise fix this right now.

After #10278, we were essentially passing full message objects from MESSAGE_CREATE to getChannel, messages, which, have a type property, often 0, which lead to a successful channel creation with jank data.

With this fix, we're back to the old behavior of dropping those events. Regarding the properties I chose to forward, I followed the payload docs found here https://discord.com/developers/docs/topics/gateway-events#gateway-events

@didinele didinele requested a review from a team as a code owner August 7, 2024 16:55
Copy link

vercel bot commented Aug 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 6:11pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Aug 7, 2024 6:11pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

TypeError: thread.members._add is not a function
2 participants