fix(aurora): fixing user dm messages in addrole
Some checks failed
Actions / Lint Code (Pylint) (push) Failing after 17s
Actions / Build Documentation (MkDocs) (push) Successful in 12s

This commit is contained in:
Seaswimmer 2024-02-02 12:05:05 -05:00
parent 21dabccb48
commit 7d2b71667a
Signed by: cswimr
GPG key ID: B8953EC01E5C4063
2 changed files with 26 additions and 6 deletions

View file

@ -372,9 +372,10 @@ class Aurora(commands.Cog):
guild=interaction.guild, guild=interaction.guild,
moderator=interaction.user, moderator=interaction.user,
reason=reason, reason=reason,
moderation_type=f"`{role.name}` role", moderation_type=f"addrole",
response=await interaction.original_response(), response=await interaction.original_response(),
duration=parsed_time, duration=parsed_time,
role=role
) )
await target.send(embed=embed) await target.send(embed=embed)
except discord.errors.HTTPException: except discord.errors.HTTPException:
@ -1078,6 +1079,13 @@ class Aurora(commands.Cog):
f"\n**Timestamp:** <t:{case['timestamp']}> | <t:{case['timestamp']}:R>" f"\n**Timestamp:** <t:{case['timestamp']}> | <t:{case['timestamp']}:R>"
) )
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"]): if bool(case["resolved"]):
field_value += "\n**Resolved:** True" field_value += "\n**Resolved:** True"

View file

@ -4,7 +4,16 @@ from datetime import datetime, timedelta
from typing import Union from typing import Union
import humanize 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 import commands
from redbot.core.utils.chat_formatting import bold, box, error, warning from redbot.core.utils.chat_formatting import bold, box, error, warning
@ -26,6 +35,7 @@ async def message_factory(
moderator: Union[Member, User] = None, moderator: Union[Member, User] = None,
duration: timedelta = None, duration: timedelta = None,
response: InteractionMessage = None, response: InteractionMessage = None,
role: Role = None,
) -> Embed: ) -> Embed:
"""This function creates a message from set parameters, meant for contacting the moderated user. """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. 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. duration (timedelta, optional): The duration of the moderation. Defaults to None.
response (InteractionMessage, optional): The response message. 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: Returns:
embed: The message embed. embed: The message embed.
@ -58,10 +70,10 @@ async def message_factory(
if moderation_type == "note": if moderation_type == "note":
embed_desc = "received a" embed_desc = "received a"
elif moderation_type == "role added": elif moderation_type == "addrole":
embed_desc = "received the" embed_desc = f"received the {role.name} role"
elif moderation_type == "role removed": elif moderation_type == "removerole":
embed_desc = "lost the" embed_desc = f"lost the {role.name} role"
else: else:
embed_desc = "been" embed_desc = "been"