sync: auto-sync from GURU-BEAST-ROG at 2026-06-05 15:42:37

Author: Mike Swanson
Machine: GURU-BEAST-ROG
Timestamp: 2026-06-05 15:42:37
This commit is contained in:
2026-06-05 15:42:43 -07:00
parent fd0b0125e0
commit fc36218960
3 changed files with 104 additions and 4 deletions

View File

@@ -75,14 +75,39 @@ async def on_ready():
@bot.event
async def on_message(message: discord.Message):
logger.info("[DEBUG] on_message fired: author=%s bot=%s channel=%s content_len=%d mentions=%d",
logger.info("[DEBUG] on_message fired: author=%s bot=%s channel=%s content_len=%d mentions=%d role_mentions=%d",
message.author.name, message.author.bot, getattr(message.channel, 'name', 'DM'),
len(message.content), len(message.mentions))
len(message.content), len(message.mentions), len(message.role_mentions))
if message.author.bot:
return
is_mention = bot.user in message.mentions
# discord.py's message.mentions can fail to resolve in some channel permission
# configurations — fall back to checking the raw message content for the bot's
# snowflake ID so @mentions always trigger regardless of cache state.
bot_mention_in_content = (
bot.user is not None
and (
f"<@{bot.user.id}>" in message.content
or f"<@!{bot.user.id}>" in message.content
)
)
# Discord creates an integration role for the bot with the same display name.
# Some users (e.g. from autocomplete) ping that role instead of the bot user —
# both look identical in chat. Detect it by checking if any of the bot's guild
# roles appear in the message's role_mentions list.
bot_role_mentioned = (
bot.user is not None
and message.guild is not None
and bool(message.role_mentions)
and (
bot_member := message.guild.get_member(bot.user.id)
) is not None
and any(role in message.role_mentions for role in bot_member.roles)
)
is_mention = bot.user in message.mentions or bot_mention_in_content or bot_role_mentioned
is_in_bot_thread = (
isinstance(message.channel, discord.Thread)
and message.channel.owner_id == bot.user.id