From 67142c64589739024716c7d00c14652fbd9770b1 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 3 May 2024 20:37:01 -0400 Subject: [PATCH] fix(aurora): added more verbose debug logging to the expiry task --- aurora/aurora.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index b767ff7..73bbf62 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -1628,7 +1628,7 @@ class Aurora(commands.Cog): target_ids = [row[0] for row in result] moderation_ids = [row[1] for row in result] - num = 0 + unban_num = 0 for target_id, moderation_id in zip(target_ids, moderation_ids): user: discord.User = await self.bot.fetch_user(target_id) name = ( @@ -1660,7 +1660,7 @@ class Aurora(commands.Cog): guild.name, guild.id, ) - num = num + 1 + unban_num = unban_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1675,6 +1675,7 @@ class Aurora(commands.Cog): e, ) + removerole_num = 0 addrole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'ADDROLE' AND expired = 0" try: cursor.execute(addrole_query, (time.time(),)) @@ -1699,6 +1700,8 @@ class Aurora(commands.Cog): await member.remove_roles( role, reason=f"Automatic role removal from case #{moderation_id}" ) + + removerole_num = removerole_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1706,6 +1709,7 @@ class Aurora(commands.Cog): ): continue + addrole_num = 0 removerole_query = f"SELECT target_id, moderation_id, role_id FROM moderation_{guild.id} WHERE end_timestamp != 0 AND end_timestamp <= ? AND moderation_type = 'REMOVEROLE' AND expired = 0" try: cursor.execute(removerole_query, (time.time(),)) @@ -1730,6 +1734,8 @@ class Aurora(commands.Cog): await member.add_roles( role, reason=f"Automatic role addition from case #{moderation_id}" ) + + addrole_num = addrole_num + 1 except ( discord.errors.NotFound, discord.errors.Forbidden, @@ -1742,13 +1748,15 @@ class Aurora(commands.Cog): per_guild_completion_time = (time.time() - time_per_guild) * 1000 logger.debug( - "Completed expiry loop for %s (%s) in %sms with %s users unbanned", + "Completed expiry loop for %s (%s) in %sms with %s users unbanned, %s roles added, and %s roles removed", guild.name, guild.id, f"{per_guild_completion_time:.6f}", - num, + unban_num, + addrole_num, + removerole_num, ) - global_num = global_num + num + global_num = global_num + unban_num + addrole_num + removerole_num database.commit() cursor.close() @@ -1756,7 +1764,7 @@ class Aurora(commands.Cog): completion_time = (time.time() - current_time) * 1000 logger.debug( - "Completed expiry loop in %sms with %s users unbanned", + "Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed", f"{completion_time:.6f}", global_num, )