feat(moderation): added database argument to mysql-log
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 45s

This commit is contained in:
Seaswimmer 2023-12-14 19:28:20 -05:00
parent d62ea24bd9
commit 621f29be5c
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

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