WIP: Moderation type registry #26
1 changed files with 3 additions and 0 deletions
|
@ -167,6 +167,7 @@ class Moderation(AuroraGuildModel):
|
||||||
metadata: dict = None,
|
metadata: dict = None,
|
||||||
) -> "Moderation":
|
) -> "Moderation":
|
||||||
from aurora.utilities.database import connect
|
from aurora.utilities.database import connect
|
||||||
|
from aurora.utilities.json import dumps
|
||||||
if not timestamp:
|
if not timestamp:
|
||||||
timestamp = datetime.fromtimestamp(time())
|
timestamp = datetime.fromtimestamp(time())
|
||||||
elif not isinstance(timestamp, datetime):
|
elif not isinstance(timestamp, datetime):
|
||||||
|
@ -230,6 +231,8 @@ class Moderation(AuroraGuildModel):
|
||||||
case_safe.pop("guild_id")
|
case_safe.pop("guild_id")
|
||||||
case_safe["timestamp"] = case_safe["timestamp"].timestamp()
|
case_safe["timestamp"] = case_safe["timestamp"].timestamp()
|
||||||
case_safe["end_timestamp"] = case_safe["end_timestamp"].timestamp() if case_safe["end_timestamp"] else None
|
case_safe["end_timestamp"] = case_safe["end_timestamp"].timestamp() if case_safe["end_timestamp"] else None
|
||||||
|
case_safe["changes"] = dumps(case_safe["changes"])
|
||||||
|
case_safe["metadata"] = dumps(case_safe["metadata"])
|
||||||
|
|
||||||
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_type, target_id, moderator_id, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired, changes, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_type, target_id, moderator_id, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired, changes, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
cursor.execute(sql, tuple(case_safe.values()))
|
cursor.execute(sql, tuple(case_safe.values()))
|
||||||
|
|
Loading…
Reference in a new issue