1
Fork 0
mirror of https://github.com/allthingslinux/tux.git synced 2024-10-02 16:43:12 +00:00

fix(afk.py): Ignore AFK removal if entry is recent

This commit is contained in:
wlinator 2024-09-04 03:09:39 -04:00
parent e189a4adb8
commit 10dd5af3ea

View file

@ -1,3 +1,6 @@
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
import discord
from discord.ext import commands
@ -44,16 +47,16 @@ class AFK(commands.Cog):
@commands.Cog.listener("on_message")
async def remove_afk(self, message: discord.Message):
if not message.guild:
return
if message.author.bot:
if not message.guild or message.author.bot:
return
entry = await self.db.get_afk_member(message.author.id, guild_id=message.guild.id)
if not entry:
return
if entry.since + timedelta(seconds=10) > datetime.now(ZoneInfo("UTC")):
return
assert isinstance(message.author, discord.Member)
await self.db.remove_afk(message.author.id)