From 416d67bf65cf74bdb43d47f896cd3d01fcbf4773 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 7 Mar 2024 16:21:32 -0500 Subject: [PATCH] feat(aurora): converted unmute to a hybrid command --- aurora/aurora.py | 53 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index cb996c9..7414b78 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -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(