fix: Suppress embeds correctly#38
Conversation
12d948e to
5abb82b
Compare
|
The git blame pointed me to this discord message: https://discord.com/channels/830522505605283862/830739873119207426/986027015499022386 Which has this video embedded in it from @networkException 2022-06-13_23-58-00.mp4I added the Which fixed a 'used disallowed intents' error on your branch here, as expected. But when pasting a link to a github issue for ladybirdbrowser/ladybird in my test guild, the bot did not "delete the embed" as was shown in the earlier video. Am I misunderstanding the intent of the code here? |
Send what link you tested with. If you check the code, not all links are suppressed. Additionally, no code changes have been made to this, so this would not be in scope of this pull request, but I can help out regardless. |
|
Manage messages is required for this. It wasn't checked previously, but at least now it will not error. |
|
Thanks! It works after re-adding the bot to my test server with that bot permission added. |
I cannot see this, maybe it's in a private channel? Anyway, I would refer to the third paragraph in my first comment here. |


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.