misc(aurora): working on blacklists

This commit is contained in:
Seaswimmer 2024-01-06 18:31:59 +00:00
parent b85b0fd4b2
commit 7eea8d2362
Signed by untrusted user: cswimr
GPG key ID: D74DDDDF420E13DF

View file

@ -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)