forked from cswimr/SeaCogs
feat(moderation): added evidenceformat
This commit is contained in:
parent
89facfe663
commit
c3767d919b
2 changed files with 27 additions and 3 deletions
|
@ -773,7 +773,7 @@ class Moderation(commands.Cog):
|
|||
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[str] = None):
|
||||
async def case(self, interaction: discord.Interaction, case: int, ephemeral: bool = None, evidenceformat: bool = False, changes: bool = False, export: Choice[str] = None):
|
||||
"""Check the details of a specific case.
|
||||
|
||||
Parameters
|
||||
|
@ -799,6 +799,8 @@ class Moderation(commands.Cog):
|
|||
if case != 0:
|
||||
case_dict = await fetch_case(case, interaction.guild.id)
|
||||
if case_dict:
|
||||
if evidenceformat:
|
||||
await interaction.response.edit_message(content=f"```Case #{case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: ```", ephemeral=ephemeral)
|
||||
if export:
|
||||
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"
|
||||
|
@ -819,9 +821,13 @@ class Moderation(commands.Cog):
|
|||
return
|
||||
if changes:
|
||||
embed = await embed_factory('changes', await self.bot.get_embed_color(None), interaction=interaction, case_dict=case_dict)
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
elif evidenceformat:
|
||||
content = await embed_factory('evidenceformat', await self.bot.get_embed_color(None), interaction=interaction, case_dict=case_dict)
|
||||
await interaction.response.send_message(content=content, ephemeral=ephemeral)
|
||||
else:
|
||||
embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=case_dict)
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
await interaction.response.send_message(embed=embed, ephemeral=ephemeral)
|
||||
return
|
||||
await interaction.response.send_message(content=f"No case with case number `{case}` found.", ephemeral=True)
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
- case_dict
|
||||
- resolved (optional)
|
||||
|
||||
Required arguments for 'case' & 'changes':
|
||||
Required arguments for 'case', 'changes', and `evidenceformat`:
|
||||
- interaction
|
||||
- case_dict"""
|
||||
if embed_type == 'message':
|
||||
|
@ -122,6 +122,24 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
|
|||
|
||||
return embed
|
||||
|
||||
if embed_type == 'evidenceformat':
|
||||
if case_dict['target_type'] == 'USER':
|
||||
target_user = await fetch_user_dict(interaction, case_dict['target_id'])
|
||||
target_name = {target_user['name']} if target_user['discriminator'] == "0" else f"{target_user['name']}#{target_user['discriminator']}"
|
||||
|
||||
elif case_dict['target_type'] == 'CHANNEL':
|
||||
target_user = await fetch_channel_dict(interaction, case_dict['target_id'])
|
||||
target_name = target_user['name']
|
||||
|
||||
content = f"```Case #{case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\n\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})"
|
||||
|
||||
if case_dict['duration'] != 'NULL':
|
||||
content += f"**Duration:** {humanize.precisedelta(td)}"
|
||||
|
||||
content += f"\nReason: {case_dict['reason']}```"
|
||||
|
||||
return content
|
||||
|
||||
if embed_type == 'log':
|
||||
if resolved:
|
||||
if case_dict['target_type'] == 'USER':
|
||||
|
|
Loading…
Reference in a new issue