refactor(actions): safer getChannel calls #10434
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theTHREAD_UPDATE
. The latter normally comes first and populates our cache, which yields to the subsequentgetChannel
caused by theMESSAGE_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
togetChannel
, messages, which, have atype
property, often0
, 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