fix: Suppress embeds correctly #38
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.
The existing implementation is not correct.
First of all, there is no message content intent. That means you receive no embeds, and thus, this entire code path is doing nothing at all.
Unfurls in Discord are sent in the embeds array. The message content intent is required for this to populate. Furthermore, unfurls do not always happen on message create. Unfurls may take a few seconds, maybe 5 at maximum, to unfurl. When it doesn't arrive on message create, it arrives on message update.
It seems clear this line was added to attempt to fix the issue:
discord-bot/src/index.ts
Line 67 in bd1aa26
However, it's not actually fixing the issue. It just seems like it does because you're waiting for an API call to resolve. It's a coincidence.
The code has been refactored into a function that utilises both message create and message update. Also, since updating a message triggers message update, an early exit check has been added.
Important
I can see LadybirdBot does not have the message content intent enabled in the developer portal. That must be switched on for this to merge.