WIP: Refactor Aurora (3.0.0) #29
1 changed files with 5 additions and 4 deletions
|
@ -1,6 +1,5 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from itertools import chain
|
|
||||||
from time import time
|
from time import time
|
||||||
from typing import Any, Dict, List, Literal, Optional, Union
|
from typing import Any, Dict, List, Literal, Optional, Union
|
||||||
|
|
||||||
|
@ -229,23 +228,25 @@ class Moderation(AuroraGuildModel):
|
||||||
}
|
}
|
||||||
|
|
||||||
case_safe = case.copy()
|
case_safe = case.copy()
|
||||||
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["changes"] = dumps(case_safe["changes"])
|
||||||
case_safe["metadata"] = dumps(case_safe["metadata"])
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
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_sql.values()))
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
database.commit()
|
database.commit()
|
||||||
if close_db:
|
if close_db:
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
|
case_safe.update({"guild_id": guild_id})
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",
|
"Row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s",
|
||||||
tuple(chain({"guild_id": guild_id}.values(), case_safe.values()))
|
tuple(case_safe.values())
|
||||||
)
|
)
|
||||||
|
|
||||||
return cls.from_dict(bot=bot, **case)
|
return cls.from_dict(bot=bot, **case)
|
||||||
|
|
Loading…
Reference in a new issue