fix(moderation): fixed evidenceformat

This commit is contained in:
Seaswimmer 2023-12-18 17:45:02 -05:00
parent 424a22672b
commit e480399ab8
Signed by untrusted user: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -32,6 +32,7 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
Required arguments for 'case', 'changes', and `evidenceformat`:
- interaction
- case_dict"""
codeblock = '```'
if embed_type == 'message':
if moderation_type in ["kicked", "banned", "tempbanned", "unbanned"]:
@ -84,12 +85,12 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
if case_dict['metadata']['imported_from']:
embed.description += f"\n**Imported From:** {case_dict['metadata']['imported_from']}"
embed.add_field(name='Reason', value=f"```{case_dict['reason']}```", inline=False)
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
if case_dict['resolved'] == 1:
resolved_user = await fetch_user_dict(interaction, case_dict['resolved_by'])
resolved_name = f"`{resolved_user['name']}`" if resolved_user['discriminator'] == "0" else f"`{resolved_user['name']}#{resolved_user['discriminator']}`"
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n```{case_dict['resolve_reason']}```", inline=False)
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n{codeblock}{case_dict['resolve_reason']}{codeblock}", inline=False)
return embed
@ -131,12 +132,15 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
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']})"
moderator_user = await fetch_user_dict(interaction, case_dict['moderator_id'])
moderator_name = {moderator_user['name']} if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
content = f"{codeblock}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']}```"
content += f"\nReason: {case_dict['reason']}{codeblock}"
return content
@ -164,11 +168,11 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
duration_embed = f"{humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>" if case_dict["expired"] == '0' else str(humanize.precisedelta(td))
embed.description = embed.description + f"\n**Duration:** {duration_embed}\n**Expired:** {bool(case_dict['expired'])}"
embed.add_field(name='Reason', value=f"```{case_dict['reason']}```", inline=False)
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
resolved_user = await fetch_user_dict(interaction, case_dict['resolved_by'])
resolved_name = resolved_user['name'] if resolved_user['discriminator'] == "0" else f"{resolved_user['name']}#{resolved_user['discriminator']}"
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n```{case_dict['resolve_reason']}```", inline=False)
embed.add_field(name='Resolve Reason', value=f"Resolved by {resolved_name} ({resolved_user['id']}) for:\n{codeblock}{case_dict['resolve_reason']}{codeblock}", inline=False)
else:
if case_dict['target_type'] == 'USER':
target_user = await fetch_user_dict(interaction, case_dict['target_id'])
@ -190,7 +194,7 @@ async def embed_factory(embed_type: str, color: Color, /, interaction: Interact
td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case_dict["duration"].split(":"))})
embed.description = embed.description + f"\n**Duration:** {humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>"
embed.add_field(name='Reason', value=f"```{case_dict['reason']}```", inline=False)
embed.add_field(name='Reason', value=f"{codeblock}{case_dict['reason']}{codeblock}", inline=False)
return embed
raise(TypeError("'type' argument is invalid!"))