forked from cswimr/SeaCogs
fix(moderation): hopefully fixed exports not exporting as files
This commit is contained in:
parent
e91cd10ce6
commit
af9db8cc58
1 changed files with 5 additions and 5 deletions
|
@ -1137,10 +1137,10 @@ class Moderation(commands.Cog):
|
||||||
|
|
||||||
@app_commands.command(name="case")
|
@app_commands.command(name="case")
|
||||||
@app_commands.choices(export=[
|
@app_commands.choices(export=[
|
||||||
Choice(name="Export as File", value='file'),
|
Choice(name="Export as File", value=1),
|
||||||
Choice(name='Export as Codeblock', value='codeblock')
|
Choice(name='Export as Codeblock', value=2)
|
||||||
])
|
])
|
||||||
async def case(self, interaction: discord.Interaction, case: int, ephemeral: bool = None, changes: bool = False, export: Choice[str] = None):
|
async def case(self, interaction: discord.Interaction, case: int, ephemeral: bool = None, changes: bool = False, export: Choice[int] = None):
|
||||||
"""Check the details of a specific case.
|
"""Check the details of a specific case.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -1167,13 +1167,13 @@ class Moderation(commands.Cog):
|
||||||
case_dict = await self.fetch_case(case, interaction.guild.id)
|
case_dict = await self.fetch_case(case, interaction.guild.id)
|
||||||
if case_dict:
|
if case_dict:
|
||||||
if export:
|
if export:
|
||||||
if export == 'file' or len(str(case)) > 1800:
|
if export == 1 or len(str(case_dict)) > 1800: # If exporting as file or if case is too large to export as codeblock
|
||||||
filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}_case_{case}.json"
|
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:
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
json.dump(case_dict, f, indent=2)
|
json.dump(case_dict, f, indent=2)
|
||||||
|
|
||||||
if export == 'codeblock':
|
if export == 2: # If exporting as codeblock
|
||||||
content = f"Case #{case} exported.\n*Case was too large to export as codeblock, so it has been uploaded as a `.json` file.*"
|
content = f"Case #{case} exported.\n*Case was too large to export as codeblock, so it has been uploaded as a `.json` file.*"
|
||||||
else:
|
else:
|
||||||
content = f"Case #{case} exported."
|
content = f"Case #{case} exported."
|
||||||
|
|
Loading…
Reference in a new issue