feat(bot): ✨ Keep track of who unbanned a user.

This commit is contained in:
Nyeki.py
2024-10-27 16:55:42 -03:00
parent 9e99211dda
commit 0e90f7b320
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -246,16 +246,22 @@ class Payphone(commands.AutoShardedBot):
@transactions.atomic()
async def unban(
self, user: discord.User | discord.Member | models.User | int
self,
user: discord.User | discord.Member | models.User | int,
unbanned_by: discord.User | discord.Member | models.User | int | None = None,
) -> None:
"""Unbans a user from Payphone.
Args:
user (discord.User | discord.Member | models.User | int): The user to unban or their
ID.
unbanned_by (discord.User | discord.Member | models.User | int | None, optional): The
moderator who unbanned the user or their ID.
"""
user_id = user if isinstance(user, int) else user.id
unbanned_by_id = unbanned_by if isinstance(unbanned_by, int) else unbanned_by.id
key = constants.BAN_TEMPLATE % user_id
await models.Ban.filter(
@@ -265,7 +271,7 @@ class Payphone(commands.AutoShardedBot):
join_type="OR",
),
user_id=user_id,
).update(expires_at=datetime.now(timezone.utc))
).update(expires_at=datetime.now(timezone.utc), unbanned_by_id=unbanned_by_id)
await self.redis.set(key, "0", ex=300)
+1 -1
View File
@@ -100,7 +100,7 @@ class Mods(base.Cog):
user_id = user
await self.bot.unban(user_id)
await self.bot.unban(user_id, ctx.author)
profile = await models.Profile.filter(user_id=user_id).limit(1).first()