fix(aurora): discriminators will only be shown if the user is on the legacy username system

This commit is contained in:
Seaswimmer 2024-01-02 03:40:35 -05:00
parent 78071ac475
commit 1ff240706c
Signed by untrusted user: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -967,6 +967,7 @@ class Aurora(commands.Cog):
num = 0
for target_id, moderation_id in zip(target_ids, moderation_ids):
user: discord.User = await self.bot.fetch_user(target_id)
name = f"{user.name}#{user.discriminator}" if user.discriminator != "0" else user.name
try:
await guild.unban(user, reason=f"Automatic unban from case #{moderation_id}")
@ -977,10 +978,10 @@ class Aurora(commands.Cog):
except discord.errors.HTTPException:
pass
logger.debug("Unbanned %s#%s (%s) from %s (%s)", user.name, user.discriminator, user.id, guild.name, guild.id)
logger.debug("Unbanned %s (%s) from %s (%s)", name, user.id, guild.name, guild.id)
num = num + 1
except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException) as e:
logger.error("Failed to unban %s#%s (%s) from %s (%s)\n%s", user.name, user.discriminator, user.id, guild.name, guild.id, e)
logger.error("Failed to unban %s (%s) from %s (%s)\n%s", name, user.id, guild.name, guild.id, e)
expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0 AND moderation_type != 'BLACKLIST') OR (expired = 0 AND resolved = 1 AND moderation_type != 'BLACKLIST')"
cursor.execute(expiry_query, (time.time(),))