Skip to content

Commit

Permalink
fix(afk): Fix a bug with multiple mentions in an AFK ping
Browse files Browse the repository at this point in the history
  • Loading branch information
wlinator committed Nov 1, 2024
1 parent be360d3 commit a63872a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tux/cogs/utility/afk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import textwrap
from datetime import datetime, timedelta
from typing import cast
from zoneinfo import ZoneInfo

import discord
Expand Down Expand Up @@ -116,19 +117,19 @@ async def check_afk(self, message: discord.Message) -> None:
if message.author.bot:
return

afks_mentioned: list[AFKModel] = []
afks_mentioned: list[tuple[discord.Member, AFKModel]] = []

for mentioned in message.mentions:
entry = await self.db.get_afk_member(mentioned.id, guild_id=message.guild.id)
if entry:
afks_mentioned.append(entry)
afks_mentioned.append((cast(discord.Member, mentioned), entry))

if not afks_mentioned:
return

msgs: list[str] = [
f"{mentioned.mention} is currently AFK: `{afk.reason}` (<t:{int(afk.since.timestamp())}:R>)"
for mentioned, afk in zip(message.mentions, afks_mentioned, strict=False)
for mentioned, afk in afks_mentioned
]

await message.reply(
Expand Down

0 comments on commit a63872a

Please sign in to comment.