fix(aurora): cleaned up addrole

This commit is contained in:
Seaswimmer 2024-02-02 11:36:46 -05:00
parent c9c2e1f955
commit 4ca9760284
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -58,7 +58,7 @@ class Aurora(commands.Cog):
This cog stores all of its data in an SQLite database."""
__author__ = "SeaswimmerTheFsh"
__version__ = "2.0.4"
__version__ = "2.0.5"
async def red_delete_data_for_user(self, *, requester, user_id: int):
if requester == "discord_deleted_user":
@ -347,7 +347,7 @@ class Aurora(commands.Cog):
matching_role = None
for role_id in addrole_whitelist:
if role_id == role:
if role_id == role.id:
matching_role = role_id
break
@ -362,15 +362,13 @@ class Aurora(commands.Cog):
):
return
if role in [role.id for role in target.roles]:
if role in [user_role.id for user_role in target.roles]:
await interaction.response.send_message(
content=error(f"{target.mention} already has this role!"),
ephemeral=True,
)
return
role_obj = interaction.guild.get_role(role)
if silent is None:
silent = not await config.guild(interaction.guild).dm_users()
if silent is False:
@ -380,7 +378,7 @@ class Aurora(commands.Cog):
guild=interaction.guild,
moderator=interaction.user,
reason=reason,
moderation_type=f"`{role_obj.name}` role",
moderation_type=f"`{role.name}` role",
response=await interaction.original_response(),
duration=parsed_time,
)
@ -393,7 +391,7 @@ class Aurora(commands.Cog):
reason=f"Role added by {interaction.user.id}{(' for ' + {humanize.precisedelta(parsed_time)} if parsed_time != 'NULL' else '')} for: {reason}",
)
await interaction.response.send_message(
content=f"{target.mention} has been given the {role_obj.name} role{(' for ' + {humanize.precisedelta(parsed_time)} if parsed_time != 'NULL' else '')}!\n**Reason** - `{reason}`"
content=f"{target.mention} has been given the {role.mention} role{(' for ' + {humanize.precisedelta(parsed_time)} if parsed_time != 'NULL' else '')}!\n**Reason** - `{reason}`"
)
moderation_id = await mysql_log(
@ -407,7 +405,7 @@ class Aurora(commands.Cog):
reason,
)
await interaction.edit_original_response(
content=f"{target.mention} has been given the {role_obj.name} role{(' for ' + {humanize.precisedelta(parsed_time)} if parsed_time != 'NULL' else '')}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`"
content=f"{target.mention} has been given the {role.mention} role{(' for ' + {humanize.precisedelta(parsed_time)} if parsed_time != 'NULL' else '')}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`"
)
await log(interaction, moderation_id)