From 7f0d2ae153d29bd8516e6b0f11e00fecd577da79 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 18 Dec 2023 16:23:45 -0500 Subject: [PATCH] fix(moderation): fixed history command erroring on unmigrated database --- moderation/moderation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index e487c59..d289068 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -588,18 +588,12 @@ class Moderation(commands.Cog): results = cursor.fetchall() result_dict_list = [] - for result in results: - case_dict = generate_dict(result) - if case_dict['moderation_id'] == 0: - continue - result_dict_list.append(case_dict) - if export: try: filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}.json" with open(filename, "w", encoding="utf-8") as f: - json.dump(result_dict_list, f, indent=2) + json.dump(results, f, indent=2) await interaction.followup.send(file=discord.File(filename, f"moderation_{interaction.guild.id}.json"), ephemeral=ephemeral) @@ -609,6 +603,12 @@ class Moderation(commands.Cog): await interaction.followup.send(content=f"An error occured while exporting the moderation history.\nError:\n```{e}```", ephemeral=ephemeral) return + for result in results: + case_dict = generate_dict(result) + if case_dict['moderation_id'] == 0: + continue + result_dict_list.append(case_dict) + case_quantity = len(result_dict_list) page_quantity = round(case_quantity / pagesize) start_index = (page - 1) * pagesize