From cb5c1e32eba24e633305ac31fbd9a1cea758054e Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 13 Dec 2023 15:07:04 -0500 Subject: [PATCH] fix(moderation): use bool() instead of == --- moderation/moderation.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 0389f39..bc5fd20 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -255,6 +255,21 @@ class Moderation(commands.Cog): } return user_dict + async def fetch_role_dict(self, interaction: discord.Interaction, role_id: str): + """This method returns a dictionary containing either role information or a standard deleted role template.""" + try: + role = interaction.guild.get_role(role_id) + role_dict = { + 'id': role.id, + 'name': role.name + } + except discord.errors.NotFound: + role_dict = { + 'id': role_id, + 'name': 'Deleted Role' + } + return role_dict + async def embed_factory(self, embed_type: str, /, interaction: discord.Interaction = None, case_dict: dict = None, guild: discord.Guild = None, reason: str = None, moderation_type: str = None, response: discord.InteractionMessage = None, duration: timedelta = None, resolved: bool = False): """This method creates an embed from set parameters, meant for either moderation logging or contacting the moderated user. @@ -306,7 +321,7 @@ class Moderation(commands.Cog): embed.description = f"**Type:** {str.title(case_dict['moderation_type'])}\n**Target:** {target_name} ({target_user['id']})\n**Moderator:** {moderator_name} ({moderator_user['id']})\n**Resolved:** {bool(case_dict['resolved'])}\n**Timestamp:** | " if case_dict['duration'] != 'NULL': td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case_dict["duration"].split(":"))}) - duration_embed = f"{humanize.precisedelta(td)} | " if case_dict["expired"] == '0' else str(humanize.precisedelta(td)) + duration_embed = f"{humanize.precisedelta(td)} | " if bool(case_dict['expired']) is False 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) if case_dict['resolved'] == 1: @@ -747,7 +762,7 @@ class Moderation(commands.Cog): field_value = f"**Target:** `{target_name}` ({target_user['id']})\n**Moderator:** `{moderator_name}` ({moderator_user['id']})\n**Reason:** `{str(case['reason'])[:150]}`" if case['duration'] != 'NULL': td = timedelta(**{unit: int(val) for unit, val in zip(["hours", "minutes", "seconds"], case["duration"].split(":"))}) - duration_embed = f"{humanize.precisedelta(td)} | " if case["expired"] == '0' else f"{humanize.precisedelta(td)} | Expired" + duration_embed = f"{humanize.precisedelta(td)} | " if bool(case['expired']) is False else f"{humanize.precisedelta(td)} | Expired" field_value = field_value + f"\n**Duration:** {duration_embed}" if bool(case['resolved']): field_value = field_value + "\n**Resolved:** True"