feat(aurora): use the type_registry in the Moderation object
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Failing after 28s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 41s

This commit is contained in:
Seaswimmer 2024-07-06 12:03:49 -04:00
parent 134e787c42
commit 08512d0dad
Signed by: cswimr
GPG key ID: 3813315477F26F82
2 changed files with 12 additions and 3 deletions

View file

@ -12,16 +12,18 @@ from redbot.core import data_manager
from redbot.core.bot import Red
from ..utilities.logger import logger
from ..utilities.registry import type_registry
from ..utilities.utils import timedelta_to_string
from .base import AuroraGuildModel
from .change import Change
from .partials import PartialChannel, PartialRole, PartialUser
from .type import Type
class Moderation(AuroraGuildModel):
moderation_id: int
timestamp: datetime
moderation_type: str
moderation_type: Type
target_type: str
target_id: int
moderator_id: int
@ -125,7 +127,7 @@ class Moderation(AuroraGuildModel):
await self.execute(query, (
self.timestamp.timestamp(),
self.moderation_type,
self.moderation_type.moderation_type,
self.target_type,
self.moderator_id,
self.role_id,
@ -192,11 +194,15 @@ class Moderation(AuroraGuildModel):
else:
metadata = {}
moderation_type = str.lower(result[2])
if moderation_type in type_registry:
moderation_type = type_registry[moderation_type]
case = {
"moderation_id": int(result[0]),
"guild_id": int(guild_id),
"timestamp": datetime.fromtimestamp(result[1]),
"moderation_type": str(result[2]),
"moderation_type": moderation_type,
"target_type": str(result[3]),
"target_id": int(result[4]),
"moderator_id": int(result[5]),

View file

@ -5,6 +5,7 @@ from typing import Any
from redbot.core.bot import Red
from ..models.base import AuroraBaseModel
from ..models.type import Type
class JSONEncoder(json.JSONEncoder):
@ -16,6 +17,8 @@ class JSONEncoder(json.JSONEncoder):
return str(o)
case AuroraBaseModel():
return o.dump()
case Type():
return o.moderation_type
case Red():
return None
case _: