fix(discord): ignore system messages in on_message handler (#2618)

Cherry-picked from PR #2575 by ticketclosed-wontfix.

Filters out Discord system messages (thread renames, pins, member joins,
boosts) that were being treated as regular user messages.

Follow-up fix: also allow MessageType.reply (value 19) — the original
filter only allowed MessageType.default, which would silently drop all
reply-based interactions.

Added pytest.importorskip for discord dependency in tests.
This commit is contained in:
Teknium
2026-03-23 06:50:09 -07:00
committed by GitHub
parent 93dc5dee6f
commit d35df0db71
2 changed files with 104 additions and 0 deletions

View File

@@ -531,6 +531,11 @@ class DiscordAdapter(BasePlatformAdapter):
if message.author == self._client.user:
return
# Ignore Discord system messages (thread renames, pins, member joins, etc.)
# Allow both default and reply types — replies have a distinct MessageType.
if message.type not in (discord.MessageType.default, discord.MessageType.reply):
return
# Bot message filtering (DISCORD_ALLOW_BOTS):
# "none" — ignore all other bots (default)
# "mentions" — accept bot messages only when they @mention us