Skip to content

Fix Message.edit() ignoring global allowed mentions#10406

Open
Soheab wants to merge 1 commit intoRapptz:masterfrom
Soheab:fix-allowed-mentions
Open

Fix Message.edit() ignoring global allowed mentions#10406
Soheab wants to merge 1 commit intoRapptz:masterfrom
Soheab:fix-allowed-mentions

Conversation

@Soheab
Copy link
Copy Markdown
Contributor

@Soheab Soheab commented Feb 23, 2026

Summary

This PR fixes an issue where the allowed mentions configured on the bot did not apply when editing a message via (Partial)Message.edit(). As a result, the edit would still ping users etc even when mentions were explicitly disabled, forcing users to reapply the allowed mentions manually.

From what I can tell, this behavior only happens in (Partial)Message.edit().

Related help post: https://canary.discord.com/channels/336642139381301249/1475259678702440580

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@Soheab Soheab changed the title Fix global allowed mentions not applying for views Fix Message.edit() ignoring global allowed mentions Feb 23, 2026
@Rapptz
Copy link
Copy Markdown
Owner

Rapptz commented Feb 24, 2026

I'm not big on this change.

Now the library is always sending this field during a PATCH operation which is not how it's supposed to be done.

@ItsSNOWMOBILE
Copy link
Copy Markdown

I honestly agree with @Rapptz , the implementation does fix the mentioned issue. BUT, it comes at the aforementioned cost. I took an hour or two of my day to analyze the logic aaaand, the bug itself is actually easy to fix!

When content is MISSING but the caller explicitly passes allowed_mentions, the merge with the global config silently doesn't happen because previous_allowed_mentions=None. That means the per-call override bypasses the global policy instead of being layered on top of it, which is exactly how send() and all interaction edit paths treat it

The proper fix is to gate on content is not MISSING or allowed_mentions is not MISSING. This ensures that global config applies when content is being changed (original behaviour preserved), and global config is merged when the caller explicitly provides an allowed_mentions override, even without a content change
Therefore, allowed_mentions is still NOT sent on pure embed/attachment/view PATCHes, and @Rapptz 's concern is satisfied :p

@Soheab
Copy link
Copy Markdown
Contributor Author

Soheab commented Mar 25, 2026

This is something Discord should fix, as mentioning in an edit call, like users, does not notify the users. For bots, it for some reason does show the yellow background as if it did succeed, but it didn't.

AFAIK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants