fix: honor mentions config in plain-text + webhook paths#6
Open
BoredManCodes wants to merge 2 commits into
Open
fix: honor mentions config in plain-text + webhook paths#6BoredManCodes wants to merge 2 commits into
BoredManCodes wants to merge 2 commits into
Conversation
AllowedMentionsBuilder is a record with positional fields (users, roles, everyone), but MessageSender.getAllowedMentions() was passing (everyone, role, user). In the plain-text bot path this miswired the toggles directly: setting mentions.everyone=false actually blocked USER mentions while the mentions.user value drove the @everyone flag. The webhook path coincidentally worked because WebhookSender swapped the slots back on read. Pass arguments in the record's declared order and drop the compensating swap in WebhookSender.
WebhookMessageBuilder defaults its allowedMentions field to AllowedMentions.all(), and WebhookClient.send(WebhookMessage) reads the message's own field directly - the client-level setAllowedMentions on WebhookClientBuilder is never consulted on this path. So every webhook send told Discord to parse everything (including @everyone) regardless of the mentions.* config. Forward the sender's allowed mentions onto the message builder so the JSON payload actually reflects what's configured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DisLinkWebhookMessageBuilder.build()never calledsetAllowedMentionson itsWebhookMessageBuilder, and the discord-webhooks library defaults that field toAllowedMentions.all().WebhookClient.send(WebhookMessage)reads the message's own field to build the JSON body, the client-levelsetAllowedMentionswe set inWebhookSender.createWebhookClientBuilderis never consulted on this path. Result: every webhook send told Discord "parse everything," so @everyone always pinged regardless of config.Fix: forward the sender's allowed mentions onto the message builder so the JSON payload reflects the config.
Test plan
mentions.everyone=false).@everyonein the sending channel; targets received the text with no ping.mentions.everyone=trueand confirm it pings when explicitly enabled.