From eb9cb459fdec22a37595e40e3ffc3f1034c2446e Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 14 Dec 2023 19:59:22 -0500 Subject: [PATCH] feat(moderation): added exporting cases --- moderation/moderation.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 1a291ea..7aa4af6 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -1104,7 +1104,7 @@ class Moderation(commands.Cog): database.close() @app_commands.command(name="case") - async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False, changes: bool = False): + async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False, changes: bool = False, export: bool = False): """Check the details of a specific case. Parameters @@ -1121,6 +1121,16 @@ class Moderation(commands.Cog): if case_number != 0: case = await self.fetch_case(case_number, interaction.guild.id) if case: + if export: + filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}_case_{case_number}.json" + + with open(filename, "w", encoding="utf-8") as f: + json.dump(case, f, indent=2) + + await interaction.response.send_message(file=discord.File(filename, f"moderation_{interaction.guild.id}_case_{case_number}.json"), ephemeral=ephemeral) + + os.remove(filename) + return if changes: embed = await self.embed_factory('changes', interaction=interaction, case_dict=case) else: