WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 342 commits from aurora-pydantic into main
4 changed files with 14 additions and 10 deletions
Showing only changes of commit bf945ec9f1 - Show all commits

View file

@ -313,7 +313,7 @@ class Moderation(AuroraGuildModel):
bot: Red, bot: Red,
guild_id: int, guild_id: int,
moderator_id: int, moderator_id: int,
moderation_type: str, moderation_type: Type,
target_type: str, target_type: str,
target_id: int, target_id: int,
role_id: int | None = None, role_id: int | None = None,
@ -373,7 +373,7 @@ class Moderation(AuroraGuildModel):
case = { case = {
"moderation_id": moderation_id, "moderation_id": moderation_id,
"timestamp": timestamp.timestamp(), "timestamp": timestamp.timestamp(),
"moderation_type": moderation_type, "moderation_type": moderation_type.key,
"target_type": target_type, "target_type": target_type,
"target_id": target_id, "target_id": target_id,
"moderator_id": moderator_id, "moderator_id": moderator_id,

View file

@ -21,7 +21,8 @@ def get_icon(bot: Red) -> File:
@type_registry.register(key="ban") @type_registry.register(key="ban")
class Ban(Type): class Ban(Type):
moderation_type="ban" key="ban"
string="ban"
verb="banned" verb="banned"
@classmethod @classmethod
@ -62,7 +63,7 @@ class Ban(Type):
bot, bot,
ctx.guild.id, ctx.guild.id,
ctx.author.id, ctx.author.id,
cls.moderation_type, cls(),
'user', 'user',
target.id, target.id,
None, None,
@ -99,7 +100,8 @@ class Ban(Type):
@type_registry.register(key="tempban") @type_registry.register(key="tempban")
class Tempban(Ban): class Tempban(Ban):
moderation_type="tempban" key="tempban"
string="tempban"
verb="tempbanned" verb="tempbanned"
@classmethod @classmethod
@ -148,7 +150,7 @@ class Tempban(Ban):
bot, bot,
ctx.guild.id, ctx.guild.id,
ctx.author.id, ctx.author.id,
cls.moderation_type, cls(),
'user', 'user',
target.id, target.id,
None, None,

View file

@ -6,13 +6,15 @@ from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
#@type_registry.register(key="type")
class Type(object): class Type(object):
moderation_type = None key = "type" # this should ALWAYS be the same as the registry key, and should NEVER be localized
verb = None string = "type"
verb = "typed"
embed_desc = "been" embed_desc = "been"
def __str__(self) -> str: def __str__(self) -> str:
return self.moderation_type return self.string
@classmethod @classmethod
async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, **kwargs) -> 'Type': # pylint: disable=unused-argument async def handler(cls, ctx: commands.Context, target: Member | User, silent: bool, **kwargs) -> 'Type': # pylint: disable=unused-argument

View file

@ -42,7 +42,7 @@ async def message_factory(
Returns: Returns:
embed: The message embed. embed: The message embed.
""" """
if response is not None and moderation_type.moderation_type not in [ if response is not None and moderation_type.key not in [
"kick", "kick",
"ban", "ban",
"tempban", "tempban",