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()