From 17617e43993f481c12453f6b4e35684d5715344b Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:19:41 -0700 Subject: [PATCH] =?UTF-8?q?feat(discord):=20DISCORD=5FIGNORE=5FNO=5FMENTIO?= =?UTF-8?q?N=20=E2=80=94=20skip=20messages=20that=20@mention=20others=20bu?= =?UTF-8?q?t=20not=20the=20bot=20(#3640)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Salvage of PR #3310 (luojiesi). When DISCORD_IGNORE_NO_MENTION=true (default), messages that @mention other users but not the bot are silently skipped in server channels. DMs excluded — mentions there are just references. Co-Authored-By: luojiesi --- gateway/platforms/discord.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index 7ee1d3d79..7c735e624 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -550,6 +550,22 @@ class DiscordAdapter(BasePlatformAdapter): return # "all" falls through to handle_message + # If the message @mentions other users but NOT the bot, the + # sender is talking to someone else — stay silent. Only + # applies in server channels; in DMs the user is always + # talking to the bot (mentions are just references). + # Controlled by DISCORD_IGNORE_NO_MENTION (default: true). + _ignore_no_mention = os.getenv( + "DISCORD_IGNORE_NO_MENTION", "true" + ).lower() in ("true", "1", "yes") + if _ignore_no_mention and message.mentions and not isinstance(message.channel, discord.DMChannel): + _bot_mentioned = ( + self._client.user is not None + and self._client.user in message.mentions + ) + if not _bot_mentioned: + return # Talking to someone else, don't interrupt + await self._handle_message(message) @self._client.event