WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
3 changed files with 9 additions and 7 deletions
Showing only changes of commit 7b3608e264 - Show all commits

View file

@ -651,7 +651,7 @@ class Unmute(Type):
guild=ctx.guild, guild=ctx.guild,
moderator=ctx.author, moderator=ctx.author,
reason=reason, reason=reason,
moderation_type="unmuted", moderation_type=cls(),
response=response_message, response=response_message,
) )
await target.send(embed=embed, file=get_icon(ctx.bot)) await target.send(embed=embed, file=get_icon(ctx.bot))
@ -679,6 +679,7 @@ class Kick(Type):
key="kick" key="kick"
string="kick" string="kick"
verb="kicked" verb="kicked"
removes_from_guild=True
def void(self) -> None: def void(self) -> None:
return None return None
@ -740,6 +741,7 @@ class Ban(Type):
key="ban" key="ban"
string="ban" string="ban"
verb="banned" verb="banned"
removes_from_guild=True
def void(self) -> None: def void(self) -> None:
return None return None
@ -824,6 +826,7 @@ class Tempban(Ban):
key="tempban" key="tempban"
string="tempban" string="tempban"
verb="tempbanned" verb="tempbanned"
removes_from_guild=True
def void(self) -> None: def void(self) -> None:
return None return None
@ -946,6 +949,7 @@ class Softban(Type):
key="softban" key="softban"
string="softban" string="softban"
verb="softbanned" verb="softbanned"
removes_from_guild=True
def void(self) -> None: def void(self) -> None:
return None return None
@ -1019,6 +1023,7 @@ class Unban(Type):
key="unban" key="unban"
string="unban" string="unban"
verb="unbanned" verb="unbanned"
removes_from_guild=True
def void(self) -> None: def void(self) -> None:
return None return None

View file

@ -17,6 +17,7 @@ class Type(metaclass=AutoRegister(type_registry)):
verb (str): The verb to use for this type. verb (str): The verb to use for this type.
embed_desc (str): The string to use for embed descriptions. 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`. 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: Properties:
name (str): The string to display for this type. This is the same as the `string` attribute. 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" verb = "typed"
embed_desc = "been " embed_desc = "been "
channel = False channel = False
removes_from_guild = False
@abstractmethod @abstractmethod
def void(self) -> Any: def void(self) -> Any:

View file

@ -42,12 +42,7 @@ async def message_factory(
Returns: Returns:
embed: The message embed. embed: The message embed.
""" """
if response is not None and moderation_type.key not in [ if response is not None and not moderation_type.removes_from_guild:
"kick",
"ban",
"tempban",
"unban",
]:
guild_name = f"[{guild.name}]({response.jump_url})" guild_name = f"[{guild.name}]({response.jump_url})"
else: else:
guild_name = guild.name guild_name = guild.name