From 621f29be5c6455a9835b5581879bd7142d35e1d7 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 14 Dec 2023 19:28:20 -0500 Subject: [PATCH] feat(moderation): added database argument to mysql-log --- moderation/moderation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 8077fd0..6d9929f 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -273,7 +273,7 @@ class Moderation(commands.Cog): return False - async def mysql_log(self, guild_id: str, author_id: str, moderation_type: str, target_id: int, role_id: int, duration, reason: str): + async def mysql_log(self, guild_id: str, author_id: str, moderation_type: str, target_id: int, role_id: int, duration, reason: str, database: mysql.connector.MySQLConnection = None): timestamp = int(time.time()) if duration != "NULL": @@ -282,7 +282,8 @@ class Moderation(commands.Cog): else: end_timestamp = 0 - database = await self.connect() + if not database: + database = await self.connect() cursor = database.cursor() moderation_id = await self.get_next_case_number(guild_id=guild_id, cursor=cursor) @@ -291,6 +292,7 @@ class Moderation(commands.Cog): val = (moderation_id, timestamp, moderation_type, target_id, author_id, role_id, duration, end_timestamp, f"{reason}", 0, "NULL", "NULL", 0, []) cursor.execute(sql, val) + cursor.close() database.commit() database.close()