WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit 1c941462df - Show all commits

View file

@ -1114,6 +1114,7 @@ class Aurora(commands.Cog):
global_addrole_num = 0 global_addrole_num = 0
global_removerole_num = 0 global_removerole_num = 0
global_other_num = 0 global_other_num = 0
global_err_num = 0
guilds: list[discord.Guild] = self.bot.guilds guilds: list[discord.Guild] = self.bot.guilds
for guild in guilds: for guild in guilds:
@ -1127,6 +1128,7 @@ class Aurora(commands.Cog):
removerole_num = 0 removerole_num = 0
addrole_num = 0 addrole_num = 0
other_num = 0 other_num = 0
error_num = 0
for moderation in moderations: for moderation in moderations:
try: try:
num = await moderation.type.expiry_handler(moderation) num = await moderation.type.expiry_handler(moderation)
@ -1135,6 +1137,7 @@ class Aurora(commands.Cog):
continue continue
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
logger.exception("Expiry handler failed for moderation %s with the type %s", moderation.id, moderation.type.key, exc_info=e) logger.exception("Expiry handler failed for moderation %s with the type %s", moderation.id, moderation.type.key, exc_info=e)
error_num += 1
continue continue
match moderation.type.key: match moderation.type.key:
case "tempban": case "tempban":
@ -1151,10 +1154,11 @@ class Aurora(commands.Cog):
per_guild_completion_time = (time.time() - time_per_guild) * 1000 per_guild_completion_time = (time.time() - time_per_guild) * 1000
logger.debug( logger.debug(
"Completed expiry loop for %s (%s) in %sms with %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)", "Completed expiry loop for %s (%s) in %sms with %s errors, %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
guild.name, guild.name,
guild.id, guild.id,
f"{per_guild_completion_time:.6f}", f"{per_guild_completion_time:.6f}",
error_num,
unban_num, unban_num,
addrole_num, addrole_num,
removerole_num, removerole_num,
@ -1164,12 +1168,14 @@ class Aurora(commands.Cog):
global_addrole_num = global_addrole_num + addrole_num global_addrole_num = global_addrole_num + addrole_num
global_removerole_num = global_removerole_num + removerole_num global_removerole_num = global_removerole_num + removerole_num
global_other_num = global_other_num + other_num global_other_num = global_other_num + other_num
global_err_num = global_err_num + error_num
completion_time = (time.time() - current_time) * 1000 completion_time = (time.time() - current_time) * 1000
logger.debug( logger.debug(
"Completed expiry loop in %sms with %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)", "Completed expiry loop in %sms with %s errors, %s users unbanned, %s roles added, and %s roles removed (%s other cases expired)",
f"{completion_time:.6f}", f"{completion_time:.6f}",
global_err_num,
global_unban_num, global_unban_num,
global_addrole_num, global_addrole_num,
global_removerole_num, global_removerole_num,