From 7eea8d236265d6888ecdc4c353d4495238e80968 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 6 Jan 2024 18:31:59 +0000 Subject: [PATCH] misc(aurora): working on blacklists --- aurora/aurora.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 98fb515..9f68a28 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -207,17 +207,8 @@ class Aurora(commands.Cog): case = await fetch_case(moderation_id, interaction.guild.id) await send_evidenceformat(interaction, case) - async def blacklist_autocomplete(self, interaction: discord.Interaction, current: str,) -> list[app_commands.Choice[str]]: # pylint: disable=unused-argument - """Autocompletes a blacklist role.""" - blacklist_roles = await config.guild(interaction.guild).blacklist_roles() - - if blacklist_roles: - return [app_commands.Choice(name=role.name, value=role.id) for role in interaction.guild.roles if role.id in blacklist_roles] - return [] - @app_commands.command(name="blacklist") - @app_commands.autocomplete(role=blacklist_autocomplete) - async def blacklist(self, interaction: discord.Interaction, target: discord.Member, role: str, reason: str, silent: bool = None): + async def blacklist(self, interaction: discord.Interaction, target: discord.Member, role: str, reason: str, duration: str = None, silent: bool = None): """Add a blacklist role to a user. Parameters @@ -225,15 +216,17 @@ class Aurora(commands.Cog): target: discord.Member Who are you blacklisting? role: str - What blacklist type are you applying to the target? + What blacklist role are you applying to the target? reason: str Why are you blacklisting this user? + duration: str + How long are you blacklisting this user for? silent: bool Should the user be messaged?""" blacklist_roles = await config.guild(interaction.guild).blacklist_roles() if not blacklist_roles: - await interaction.response.send_message(content=error("There are no blacklist types set for this server!"), ephemeral=True) + await interaction.response.send_message(content=error("There are no blacklist roles set for this server!"), ephemeral=True) return matching_role = None @@ -244,7 +237,7 @@ class Aurora(commands.Cog): break if not matching_role: - await interaction.response.send_message(content=error("Please provide a valid blacklist type!"), ephemeral=True) + await interaction.response.send_message(content=error("Please provide a valid blacklist role!"), ephemeral=True) return if not await check_moddable(target, interaction, ['moderate_members', 'manage_roles']): @@ -264,10 +257,10 @@ class Aurora(commands.Cog): pass role_obj = interaction.guild.get_role(role) - await target.add_roles(role, reason=f"Blacklisted by {interaction.user.id} for {humanize.precisedelta(matching_role['duration'])} for: {reason}") + await target.add_roles(role, reason=f"Blacklisted by {interaction.user.id} for {humanize.precisedelta(duration)} for: {reason}") await interaction.response.send_message(content=f"{target.mention} has been blacklisted with the {role_obj.name} role for {humanize.precisedelta(matching_role['duration'])}!\n**Reason** - `{reason}`") - moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'BLACKLIST', 'USER', target.id, role, matching_role['duration'], reason) + moderation_id = await mysql_log(interaction.guild.id, interaction.user.id, 'BLACKLIST', 'USER', target.id, role, duration, reason) await interaction.edit_original_response(content=f"{target.mention} has been blacklisted with the {role_obj.name} role for {humanize.precisedelta(matching_role['duration'])}! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`") await log(interaction, moderation_id)