diff --git a/aurora/aurora.py b/aurora/aurora.py index e42f394..3d7d3da 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -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);"