feat(aurora): converted unmute to a hybrid command

This commit is contained in:
Seaswimmer 2024-03-07 16:21:32 -05:00
parent e2d2b7bdc1
commit 416d67bf65
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -486,29 +486,26 @@ class Aurora(commands.Cog):
case = await fetch_case(moderation_id, ctx.guild.id)
await send_evidenceformat(ctx, case)
@app_commands.command(name="unmute")
@commands.hybrid_command(name="unmute")
@commands.mod_or_permissions(moderate_members=True)
@app_commands.describe(
target="Who are you unmuting?",
reason="Why are you unmuting this user?",
silent="Should the user be messaged?",
)
async def unmute(
self,
interaction: discord.Interaction,
ctx: commands.Context,
target: discord.Member,
reason: str = None,
silent: bool = None,
):
"""Unmute a user.
Parameters
-----------
target: discord.user
Who are you unmuting?
reason: str
Why are you unmuting this user?
silent: bool
Should the user be messaged?"""
if not await check_moddable(target, interaction, ["moderate_members"]):
"""Unmute a user."""
if not await check_moddable(target, ctx, ["moderate_members"]):
return
if target.is_timed_out() is False:
await interaction.response.send_message(
await ctx.send(
error(f"{target.mention} is not muted!"),
allowed_mentions=discord.AllowedMentions(users=False),
ephemeral=True,
@ -517,35 +514,35 @@ class Aurora(commands.Cog):
if reason:
await target.timeout(
None, reason=f"Unmuted by {interaction.user.id} for: {reason}"
None, reason=f"Unmuted by {ctx.author.id} for: {reason}"
)
else:
await target.timeout(None, reason=f"Unbanned by {interaction.user.id}")
await target.timeout(None, reason=f"Unmuted by {ctx.author.id}")
reason = "No reason given."
await interaction.response.send_message(
message = await ctx.send(
content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`"
)
if silent is None:
silent = not await config.guild(interaction.guild).dm_users()
silent = not await config.guild(ctx.guild).dm_users()
if silent is False:
try:
embed = await message_factory(
await self.bot.get_embed_color(interaction.channel),
guild=interaction.guild,
moderator=interaction.user,
await ctx.embed_color(),
guild=ctx.guild,
moderator=ctx.author,
reason=reason,
moderation_type="unmuted",
response=await interaction.original_response(),
response=message,
)
await target.send(embed=embed)
except discord.errors.HTTPException:
pass
moderation_id = await mysql_log(
interaction.guild.id,
interaction.user.id,
ctx.guild.id,
ctx.author.id,
"UNMUTE",
"USER",
target.id,
@ -553,13 +550,13 @@ class Aurora(commands.Cog):
"NULL",
reason,
)
await interaction.edit_original_response(
await message.edit(
content=f"{target.mention} has been unmuted! (Case `#{moderation_id:,}`)\n**Reason** - `{reason}`"
)
await log(interaction, moderation_id)
await log(ctx, moderation_id)
case = await fetch_case(moderation_id, interaction.guild.id)
await send_evidenceformat(interaction, case)
case = await fetch_case(moderation_id, ctx.guild.id)
await send_evidenceformat(ctx, case)
@app_commands.command(name="kick")
async def kick(