From e2d2b7bdc19be44c29b3b941f4f2353bf8b123a8 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 7 Mar 2024 16:13:47 -0500 Subject: [PATCH] feat(aurora): converted mute to a hybrid command --- aurora/aurora.py | 58 ++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index 629477c..cb996c9 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -401,32 +401,28 @@ class Aurora(commands.Cog): case = await fetch_case(moderation_id, interaction.guild.id) await send_evidenceformat(interaction, case) - @app_commands.command(name="mute") + @commands.hybrid_command(name="mute") + @commands.mod_or_permissions(moderate_members=True) + @app_commands.describe( + target="Who are you muting?", + duration="How long are you muting this user for?", + reason="Why are you muting this user?", + silent="Should the user be messaged?", + ) async def mute( self, - interaction: discord.Interaction, + ctx: commands.Context, target: discord.Member, duration: str, reason: str, silent: bool = None, ): - """Mute a user. - - Parameters - ----------- - target: discord.Member - Who are you unbanning? - duration: str - How long are you muting this user for? - reason: str - Why are you unbanning this user? - silent: bool - Should the user be messaged?""" - if not await check_moddable(target, interaction, ["moderate_members"]): + """Mute a user.""" + if not await check_moddable(target, ctx, ["moderate_members"]): return if target.is_timed_out() is True: - await interaction.response.send_message( + await ctx.send( error(f"{target.mention} is already muted!"), allowed_mentions=discord.AllowedMentions(users=False), ephemeral=True, @@ -436,36 +432,36 @@ class Aurora(commands.Cog): try: parsed_time = parse(sval=duration, as_timedelta=True, raise_exception=True) except ValueError: - await interaction.response.send_message( + await ctx.send( error("Please provide a valid duration!"), ephemeral=True ) return if parsed_time.total_seconds() / 1000 > 2419200000: - await interaction.response.send_message( + await ctx.send( error("Please provide a duration that is less than 28 days.") ) return await target.timeout( - parsed_time, reason=f"Muted by {interaction.user.id} for: {reason}" + parsed_time, reason=f"Muted by {ctx.author.id} for: {reason}" ) - await interaction.response.send_message( + message = await ctx.send( content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\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="muted", - response=await interaction.original_response(), + response=message, duration=parsed_time, ) await target.send(embed=embed) @@ -473,8 +469,8 @@ class Aurora(commands.Cog): pass moderation_id = await mysql_log( - interaction.guild.id, - interaction.user.id, + ctx.guild.id, + ctx.author.id, "MUTE", "USER", target.id, @@ -482,13 +478,13 @@ class Aurora(commands.Cog): parsed_time, reason, ) - await interaction.edit_original_response( + await message.edit( content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}! (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="unmute") async def unmute(