misc(moderation): cleaned up mysql_log method
Some checks failed
Pylint / Pylint (push) Failing after 1m20s
Some checks failed
Pylint / Pylint (push) Failing after 1m20s
This commit is contained in:
parent
5136a492f8
commit
be2d97e19c
1 changed files with 5 additions and 5 deletions
|
@ -168,8 +168,7 @@ class Moderation(commands.Cog):
|
||||||
end_timestamp = 0
|
end_timestamp = 0
|
||||||
database = await self.connect()
|
database = await self.connect()
|
||||||
cursor = database.cursor()
|
cursor = database.cursor()
|
||||||
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
moderation_id = await self.get_next_case_number(guild_id=guild_id, cursor=cursor)
|
||||||
moderation_id = cursor.fetchone()[0] + 1
|
|
||||||
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_id, moderator_id, duration, end_timestamp, reason, resolved, resolve_reason, expired) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_id, moderator_id, duration, end_timestamp, reason, resolved, resolve_reason, expired) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||||
val = (moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, f"{reason}", 0, "NULL", 0)
|
val = (moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, f"{reason}", 0, "NULL", 0)
|
||||||
cursor.execute(sql, val)
|
cursor.execute(sql, val)
|
||||||
|
@ -177,8 +176,9 @@ class Moderation(commands.Cog):
|
||||||
database.close()
|
database.close()
|
||||||
logging.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
|
logging.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, 0, NULL", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, duration, end_timestamp, reason)
|
||||||
|
|
||||||
async def get_next_case_number(self, guild_id: str):
|
async def get_next_case_number(self, guild_id: str, cursor = None):
|
||||||
"""This method returns the next case number from the MySQL table for a specific guild."""
|
"""This method returns the next case number from the MySQL table for a specific guild."""
|
||||||
|
if not cursor:
|
||||||
database = await self.connect()
|
database = await self.connect()
|
||||||
cursor = database.cursor()
|
cursor = database.cursor()
|
||||||
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
cursor.execute(f"SELECT moderation_id FROM `moderation_{guild_id}` ORDER BY moderation_id DESC LIMIT 1")
|
||||||
|
|
Loading…
Reference in a new issue