WIP: Refactor Aurora (3.0.0) #29
2 changed files with 12 additions and 3 deletions
|
@ -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]),
|
||||
|
|
|
@ -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 _:
|
||||
|
|
Loading…
Reference in a new issue