From 87703daaf46e051fad2b690b7054d1af9d294230 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 15 Dec 2023 10:41:38 -0500 Subject: [PATCH] fix(moderation): fixed exporting cases --- moderation/moderation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index f7ecf13..f7ec298 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -1137,10 +1137,10 @@ class Moderation(commands.Cog): @app_commands.command(name="case") @app_commands.choices(export=[ - Choice(name="Export as File", value=1), - Choice(name='Export as Codeblock', value=2) + Choice(name='Export as File', value='file'), + Choice(name='Export as Codeblock', value='codeblock') ]) - async def case(self, interaction: discord.Interaction, case: int, ephemeral: bool = None, changes: bool = False, export: Choice[int] = None): + async def case(self, interaction: discord.Interaction, case: int, ephemeral: bool = None, changes: bool = False, export: Choice[str] = None): """Check the details of a specific case. Parameters @@ -1152,7 +1152,7 @@ class Moderation(commands.Cog): changes: bool List the changes made to the case export: bool - Export the case to a JSON file""" + Export the case to a JSON file or codeblock""" permissions = self.check_permissions(interaction.client.user, ['embed_links'], interaction) if permissions: await interaction.response.send_message(f"I do not have the `{permissions}` permission, required for this action.", ephemeral=True) @@ -1167,13 +1167,13 @@ class Moderation(commands.Cog): case_dict = await self.fetch_case(case, interaction.guild.id) if case_dict: if export: - if export == 1 or len(str(case_dict)) > 1800: # If exporting as file or if case is too large to export as codeblock + if export.value == 'file' or len(str(case_dict)) > 1800: filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}_case_{case}.json" with open(filename, "w", encoding="utf-8") as f: json.dump(case_dict, f, indent=2) - if export == 2: # If exporting as codeblock + if export.value == 'codeblock': content = f"Case #{case} exported.\n*Case was too large to export as codeblock, so it has been uploaded as a `.json` file.*" else: content = f"Case #{case} exported."