From e480399ab8431c0a258ab115c680b8b744087f69 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 18 Dec 2023 17:45:02 -0500 Subject: [PATCH] fix(moderation): fixed evidenceformat --- moderation/utilities/embed_factory.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/moderation/utilities/embed_factory.py b/moderation/utilities/embed_factory.py index f22c14f..3b3f755 100644 --- a/moderation/utilities/embed_factory.py +++ b/moderation/utilities/embed_factory.py @@ -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)} | " 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)} | " - 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!"))