feat(moderation): added database argument to mysql-log
This commit is contained in:
parent
d62ea24bd9
commit
621f29be5c
1 changed files with 4 additions and 2 deletions
|
@ -273,7 +273,7 @@ class Moderation(commands.Cog):
|
||||||
|
|
||||||
return False
|
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())
|
timestamp = int(time.time())
|
||||||
|
|
||||||
if duration != "NULL":
|
if duration != "NULL":
|
||||||
|
@ -282,7 +282,8 @@ class Moderation(commands.Cog):
|
||||||
else:
|
else:
|
||||||
end_timestamp = 0
|
end_timestamp = 0
|
||||||
|
|
||||||
database = await self.connect()
|
if not database:
|
||||||
|
database = await self.connect()
|
||||||
cursor = database.cursor()
|
cursor = database.cursor()
|
||||||
|
|
||||||
moderation_id = await self.get_next_case_number(guild_id=guild_id, cursor=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, [])
|
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.execute(sql, val)
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
database.commit()
|
database.commit()
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue