forked from cswimr/SeaCogs
feat(moderation): added exporting cases
This commit is contained in:
parent
8929a2c190
commit
eb9cb459fd
1 changed files with 11 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue