fix(moderation): case 0 will no longer be shown in history, resolve, or case
All checks were successful
Pylint / Pylint (push) Successful in 1m13s

This commit is contained in:
Seaswimmer 2023-10-06 23:51:42 -04:00
parent bde82ae975
commit 7c6fc32c88
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -557,7 +557,10 @@ class Moderation(commands.Cog):
for result in results:
case_dict = self.generate_dict(result)
result_dict_list.append(case_dict)
case_quantity = len(result_dict_list)
if target or moderator:
case_quantity = len(result_dict_list)
else:
case_quantity = len(result_dict_list) - 1 # account for case 0 technically existing
page_quantity = round(case_quantity / pagesize)
start_index = (page - 1) * pagesize
end_index = page * pagesize
@ -601,7 +604,7 @@ class Moderation(commands.Cog):
query_1 = "SELECT * FROM moderation_%s WHERE moderation_id = %s;"
cursor.execute(query_1, (interaction.guild.id, case_number))
result_1 = cursor.fetchone()
if result_1 is None:
if result_1 is None or case_number == 0:
await interaction.response.send_message(content=f"There is no moderation with a case number of {case_number}.", ephemeral=True)
return
query_2 = "SELECT * FROM moderation_%s WHERE moderation_id = %s AND resolved = 0;"
@ -659,7 +662,7 @@ class Moderation(commands.Cog):
result = cursor.fetchone()
cursor.close()
database.close()
if result:
if result and case_number != 0:
case = self.generate_dict(result)
embed = await self.embed_factory('case', interaction=interaction, case_dict=case)
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)