WIP: Refactor Aurora (3.0.0) #29
1 changed files with 21 additions and 6 deletions
|
@ -150,7 +150,7 @@ class Moderation(AuroraGuildModel):
|
|||
cls,
|
||||
bot: Red,
|
||||
guild_id: int,
|
||||
author_id: int,
|
||||
moderator_id: int,
|
||||
moderation_type: str,
|
||||
target_type: str,
|
||||
target_id: int,
|
||||
|
@ -214,7 +214,7 @@ class Moderation(AuroraGuildModel):
|
|||
"moderation_type": moderation_type,
|
||||
"target_type": target_type,
|
||||
"target_id": target_id,
|
||||
"moderator_id": author_id,
|
||||
"moderator_id": moderator_id,
|
||||
"role_id": role_id,
|
||||
"duration": duration,
|
||||
"end_timestamp": end_timestamp,
|
||||
|
@ -228,15 +228,14 @@ class Moderation(AuroraGuildModel):
|
|||
}
|
||||
|
||||
case_safe = case.copy()
|
||||
case_safe.pop("guild_id")
|
||||
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["changes"] = dumps(case_safe["changes"])
|
||||
case_safe["metadata"] = dumps(case_safe["metadata"])
|
||||
case_sql = case_safe.copy()
|
||||
case_sql.pop("guild_id")
|
||||
|
||||
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_sql.values()))
|
||||
cursor.execute(sql, tuple(case_safe.values()))
|
||||
|
||||
cursor.close()
|
||||
database.commit()
|
||||
|
@ -246,7 +245,23 @@ class Moderation(AuroraGuildModel):
|
|||
case_safe.update({"guild_id": guild_id})
|
||||
logger.debug(
|
||||
"Row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",
|
||||
tuple(case_safe.values())
|
||||
guild_id,
|
||||
case_safe["moderation_id"],
|
||||
case_safe["timestamp"],
|
||||
case_safe["moderation_type"],
|
||||
case_safe["target_type"],
|
||||
case_safe["target_id"],
|
||||
case_safe["moderator_id"],
|
||||
case_safe["role_id"],
|
||||
case_safe["duration"],
|
||||
case_safe["end_timestamp"],
|
||||
case_safe["reason"],
|
||||
case_safe["resolved"],
|
||||
case_safe["resolved_by"],
|
||||
case_safe["resolve_reason"],
|
||||
case_safe["expired"],
|
||||
case_safe["changes"],
|
||||
case_safe["metadata"],
|
||||
)
|
||||
|
||||
return cls.from_dict(bot=bot, **case)
|
||||
|
|
Loading…
Reference in a new issue