From 7b3608e2641dab2a89478891eae58aecd2d2781d Mon Sep 17 00:00:00 2001 From: cswimr Date: Mon, 19 Aug 2024 03:55:08 -0400 Subject: [PATCH] fix(aurora): fixed a keyerror in the message_factory function and cleaned up some other problems --- aurora/models/moderation_types.py | 7 ++++++- aurora/models/type.py | 2 ++ aurora/utilities/factory.py | 7 +------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/aurora/models/moderation_types.py b/aurora/models/moderation_types.py index 272ec75..2357922 100644 --- a/aurora/models/moderation_types.py +++ b/aurora/models/moderation_types.py @@ -651,7 +651,7 @@ class Unmute(Type): guild=ctx.guild, moderator=ctx.author, reason=reason, - moderation_type="unmuted", + moderation_type=cls(), response=response_message, ) await target.send(embed=embed, file=get_icon(ctx.bot)) @@ -679,6 +679,7 @@ class Kick(Type): key="kick" string="kick" verb="kicked" + removes_from_guild=True def void(self) -> None: return None @@ -740,6 +741,7 @@ class Ban(Type): key="ban" string="ban" verb="banned" + removes_from_guild=True def void(self) -> None: return None @@ -824,6 +826,7 @@ class Tempban(Ban): key="tempban" string="tempban" verb="tempbanned" + removes_from_guild=True def void(self) -> None: return None @@ -946,6 +949,7 @@ class Softban(Type): key="softban" string="softban" verb="softbanned" + removes_from_guild=True def void(self) -> None: return None @@ -1019,6 +1023,7 @@ class Unban(Type): key="unban" string="unban" verb="unbanned" + removes_from_guild=True def void(self) -> None: return None diff --git a/aurora/models/type.py b/aurora/models/type.py index d5cf568..6cc8092 100644 --- a/aurora/models/type.py +++ b/aurora/models/type.py @@ -17,6 +17,7 @@ class Type(metaclass=AutoRegister(type_registry)): verb (str): The verb to use for this type. embed_desc (str): The string to use for embed descriptions. channel (bool): Whether this type targets channels or users. If this is `true` in a subclass, its overriden handler methods should be typed with `discord.abc.Messageable` instead of `discord.Member | discord.User`. + removes_from_guild (bool): Whether this type's handler removes the target from the guild, or if the moderation is expected to occur whenever the user is not in the guild. This does not actually remove the target from the guild, the handler method is responsible for that. Properties: name (str): The string to display for this type. This is the same as the `string` attribute. @@ -27,6 +28,7 @@ class Type(metaclass=AutoRegister(type_registry)): verb = "typed" embed_desc = "been " channel = False + removes_from_guild = False @abstractmethod def void(self) -> Any: diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index 95ea1ca..b45b68a 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -42,12 +42,7 @@ async def message_factory( Returns: embed: The message embed. """ - if response is not None and moderation_type.key not in [ - "kick", - "ban", - "tempban", - "unban", - ]: + if response is not None and not moderation_type.removes_from_guild: guild_name = f"[{guild.name}]({response.jump_url})" else: guild_name = guild.name