From 7d2b71667ad663da2e4ffe2cf440e5726a3b2fa8 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 2 Feb 2024 12:05:05 -0500 Subject: [PATCH] fix(aurora): fixing user dm messages in addrole --- aurora/aurora.py | 10 +++++++++- aurora/utilities/factory.py | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 5e9a865..042a235 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -372,9 +372,10 @@ class Aurora(commands.Cog): guild=interaction.guild, moderator=interaction.user, reason=reason, - moderation_type=f"`{role.name}` role", + moderation_type=f"addrole", response=await interaction.original_response(), duration=parsed_time, + role=role ) await target.send(embed=embed) except discord.errors.HTTPException: @@ -1078,6 +1079,13 @@ class Aurora(commands.Cog): f"\n**Timestamp:** | " ) + if case["role_id"] != 0: + role = interaction.guild.get_role(case["role_id"]) + if not role: + field_value += f"\n**Role:** Deleted Role ({case['role_id']})" + else: + field_value += f"\n**Role:** {role.mention}" + if bool(case["resolved"]): field_value += "\n**Resolved:** True" diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index 34892f3..1657c81 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -4,7 +4,16 @@ from datetime import datetime, timedelta from typing import Union import humanize -from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, User +from discord import ( + Color, + Embed, + Guild, + Interaction, + InteractionMessage, + Member, + Role, + User, +) from redbot.core import commands from redbot.core.utils.chat_formatting import bold, box, error, warning @@ -26,6 +35,7 @@ async def message_factory( moderator: Union[Member, User] = None, duration: timedelta = None, response: InteractionMessage = None, + role: Role = None, ) -> Embed: """This function creates a message from set parameters, meant for contacting the moderated user. @@ -37,6 +47,8 @@ async def message_factory( moderator (Union[Member, User], optional): The moderator who performed the moderation. Defaults to None. duration (timedelta, optional): The duration of the moderation. Defaults to None. response (InteractionMessage, optional): The response message. Defaults to None. + role (Role, optional): The role that was added or removed. Defaults to None. + Returns: embed: The message embed. @@ -58,10 +70,10 @@ async def message_factory( if moderation_type == "note": embed_desc = "received a" - elif moderation_type == "role added": - embed_desc = "received the" - elif moderation_type == "role removed": - embed_desc = "lost the" + elif moderation_type == "addrole": + embed_desc = f"received the {role.name} role" + elif moderation_type == "removerole": + embed_desc = f"lost the {role.name} role" else: embed_desc = "been"