fix(aurora): finally fixed the debug logging statement (maybe)
Some checks failed
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 39s
Actions / Build Documentation (MkDocs) (pull_request) Successful in 26s

This commit is contained in:
Seaswimmer 2024-05-06 14:35:02 -04:00
parent 335d1a2a4c
commit 0386cb346e
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -1,6 +1,5 @@
import sqlite3
from datetime import datetime, timedelta
from itertools import chain
from time import time
from typing import Any, Dict, List, Literal, Optional, Union
@ -229,23 +228,25 @@ 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_safe.values()))
cursor.execute(sql, tuple(case_sql.values()))
cursor.close()
database.commit()
if close_db:
database.close()
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(chain({"guild_id": guild_id}.values(), case_safe.values()))
tuple(case_safe.values())
)
return cls.from_dict(bot=bot, **case)