fix(aurora): adding some more logging to the expiry task

This commit is contained in:
Seaswimmer 2024-05-03 20:47:19 -04:00
parent bcef643349
commit 877f5e00d3
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -1694,13 +1694,8 @@ class Aurora(commands.Cog):
try:
member = await guild.fetch_member(target_id)
role = guild.get_role(role_id)
if role is None:
logger.warning("Role %s does not exist in %s, unable to remove role from user %s", role_id, guild.id, target_id)
continue
await member.remove_roles(
role, reason=f"Automatic role removal from case #{moderation_id}"
role_id, reason=f"Automatic role removal from case #{moderation_id}"
)
removerole_num = removerole_num + 1
@ -1708,7 +1703,13 @@ class Aurora(commands.Cog):
discord.errors.NotFound,
discord.errors.Forbidden,
discord.errors.HTTPException,
):
) as e:
logger.error(
"Removing the role %s from user %s failed due to: \n%s",
role_id,
target_id,
e,
)
continue
addrole_num = 0
@ -1728,13 +1729,8 @@ class Aurora(commands.Cog):
try:
member = await guild.fetch_member(target_id)
role = guild.get_role(role_id)
if role is None:
logger.warning("Role %s does not exist in %s, unable to add role to user %s", role_id, guild.id, target_id)
continue
await member.add_roles(
role, reason=f"Automatic role addition from case #{moderation_id}"
role_id, reason=f"Automatic role addition from case #{moderation_id}"
)
addrole_num = addrole_num + 1
@ -1742,7 +1738,8 @@ class Aurora(commands.Cog):
discord.errors.NotFound,
discord.errors.Forbidden,
discord.errors.HTTPException,
):
) as e:
logger.error("Adding the role %s to user %s failed due to: \n%s", role_id, target_id, e)
continue
expiry_query = f"UPDATE `moderation_{guild.id}` SET expired = 1 WHERE (end_timestamp != 0 AND end_timestamp <= ? AND expired = 0) OR (expired = 0 AND resolved = 1);"