feat(moderation): added changes column to mysql tables
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 56s

This commit is contained in:
Seaswimmer 2023-12-14 15:50:48 -05:00
parent adbe4b4d85
commit 15ef2216ce
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -152,7 +152,8 @@ class Moderation(commands.Cog):
resolved BOOL NOT NULL, resolved BOOL NOT NULL,
resolved_by LONGTEXT, resolved_by LONGTEXT,
resolve_reason LONGTEXT, resolve_reason LONGTEXT,
expired BOOL NOT NULL expired BOOL NOT NULL,
changes JSON NOT NULL,
) )
""" """
cursor.execute(query) cursor.execute(query)
@ -164,10 +165,10 @@ class Moderation(commands.Cog):
cursor.execute(index_query_3, (guild.id,)) cursor.execute(index_query_3, (guild.id,))
insert_query = f""" insert_query = f"""
INSERT INTO `moderation_{guild.id}` INSERT INTO `moderation_{guild.id}`
(moderation_id, timestamp, moderation_type, target_id, moderator_id, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired) (moderation_id, timestamp, moderation_type, target_id, moderator_id, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired, changes)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
""" """
insert_values = (0, 0, "NULL", 0, 0, 0, "NULL", 0, "NULL", 0, "NULL", "NULL", 0) insert_values = (0, 0, "NULL", 0, 0, 0, "NULL", 0, "NULL", 0, "NULL", "NULL", 0, [])
cursor.execute(insert_query, insert_values) cursor.execute(insert_query, insert_values)
database.commit() database.commit()
self.logger.info("MySQL Table (moderation_%s) created for %s (%s)", guild.id, guild.name, guild.id) self.logger.info("MySQL Table (moderation_%s) created for %s (%s)", guild.id, guild.name, guild.id)
@ -206,12 +207,12 @@ class Moderation(commands.Cog):
database = await self.connect() 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)
sql = f"INSERT INTO `moderation_{guild_id}` (moderation_id, timestamp, moderation_type, target_id, moderator_id, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired) VALUES (%s, %s, %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, role_id, duration, end_timestamp, reason, resolved, resolved_by, resolve_reason, expired, changes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
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)
database.commit() database.commit()
database.close() database.close()
self.logger.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, %s, 0, NULL, NULL, 0", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, role_id, duration, end_timestamp, reason) self.logger.debug("MySQL row inserted into moderation_%s!\n%s, %s, %s, %s, %s, %s, %s, %s, %s, 0, NULL, NULL, 0, []", guild_id, moderation_id, timestamp, moderation_type, target_id, author_id, role_id, duration, end_timestamp, reason)
return moderation_id return moderation_id
async def get_next_case_number(self, guild_id: str, cursor = None): async def get_next_case_number(self, guild_id: str, cursor = None):
@ -236,7 +237,8 @@ class Moderation(commands.Cog):
"resolved": result[9], "resolved": result[9],
"resolved_by": result[10], "resolved_by": result[10],
"resolve_reason": result[11], "resolve_reason": result[11],
"expired": result[12] "expired": result[12],
"changes": result[13]
} }
return case return case