diff --git a/moderation/moderation.py b/moderation/moderation.py index 59d4437..7bc1a22 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -209,6 +209,25 @@ class Moderation(commands.Cog): await response.edit(content=f"{response.content}\n*Failed to send DM, user likely has the bot blocked.*") await self.mysql_log(ctx.guild.id, ctx.author.id, 'MUTE', target.id, parsed_time, reason) + @commands.hybrid_command(name="unmute", aliases=['untimeout', 'utm']) + @commands.mod() + async def unmute(self, ctx: commands.Context, target: discord.Member, *, reason: str = None): + """Unmute a user.""" + if target.is_timed_out() is False: + await ctx.send(f"{target.mention} is not muted!", allowed_mentions=discord.AllowedMentions(users=False)) + return + await target.timeout(None) + if reason is None: + reason = "No reason given." + response = await ctx.send(content=f"{target.mention} has been unmuted!\n**Reason** - `{reason}`") + try: + embed = discord.Embed(title="Unmuted", description=f"You have been unmuted in [{ctx.guild.name}]({response.jump_url}).", color=await self.bot.get_embed_color(None)) + embed.add_field(name='Reason', value=f"`{reason}`") + await target.send(embed=embed) + except discord.errors.HTTPException: + await response.edit(content=f"{response.content}\n*Failed to send DM, user likely has the bot blocked.*") + await self.mysql_log(ctx.guild.id, ctx.author.id, 'UNMUTE', target.id, 'NULL', reason) + @commands.group(autohelp=True) @checks.admin() async def moderationset(self, ctx: commands.Context):