From 009b406ff6d3203a34fc0dcc9cf30265a9ef62e1 Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Tue, 13 Aug 2024 01:30:47 -0400 Subject: [PATCH] fix(aurora): fixed some broken expiry handlers --- aurora/models/moderation_types.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/aurora/models/moderation_types.py b/aurora/models/moderation_types.py index 3b29bf4..0265145 100644 --- a/aurora/models/moderation_types.py +++ b/aurora/models/moderation_types.py @@ -241,7 +241,12 @@ class AddRole(Type): @classmethod async def expiry_handler(cls, moderation: Moderation) -> int: try: - target = await moderation.get_target() + target = moderation.bot.get_user(moderation.target_id) + if not target: + try: + await moderation.guild.fetch_member(moderation.target_id) + except NotFound: + return 0 await target.remove_roles( Object(moderation.role_id), reason=f"Automatic role removal from case #{moderation.id}" @@ -409,7 +414,12 @@ class RemoveRole(Type): @classmethod async def expiry_handler(cls, moderation: Moderation) -> int: try: - target = await moderation.get_target() + target = moderation.bot.get_user(moderation.target_id) + if not target: + try: + await moderation.guild.fetch_member(moderation.target_id) + except NotFound: + return 0 await target.add_roles( Object(moderation.role_id), reason=f"Automatic role addition from case #{moderation.id}" @@ -881,7 +891,12 @@ class Tempban(Ban): async def expiry_handler(cls, moderation: Moderation) -> int: reason = f"Automatic {Unban.string} from case #{moderation.id}" try: - target = await moderation.get_target() + target = moderation.bot.get_user(moderation.target_id) + if not target: + try: + await moderation.bot.fetch_user(moderation.target_id) + except NotFound: + return 0 await moderation.guild.unban(user=target, reason=reason) if await config.guild(moderation.guild).dm_users() is True: