feat(moderation): disabled ability to mute people who are already muted
All checks were successful
Pylint / Pylint (push) Successful in 1m12s

This commit is contained in:
Seaswimmer 2023-10-04 13:16:03 -04:00
parent 14c4e61a40
commit 6c280f25c2
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -176,8 +176,11 @@ class Moderation(commands.Cog):
@commands.hybrid_command(name="mute", aliases=['timeout'])
@commands.mod()
async def mute(self, ctx: commands.Context, target: discord.Member, duration: str, reason: str):
async def mute(self, ctx: commands.Context, target: discord.Member, duration: str, *, reason: str):
"""Mute a user."""
if target.is_timed_out() is True:
await ctx.message.reply(f"{target.mention} is already muted!", allowed_mentions=None)
return
try:
parsed_time = parse(sval=duration, as_timedelta=True, raise_exception=True)
except ValueError:
@ -186,7 +189,7 @@ class Moderation(commands.Cog):
await target.timeout(parsed_time)
response = await ctx.send(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`")
try:
embed = discord.Embed(title="Muted", description=f"You have been muted for `{humanize.precisedelta(parsed_time)}` in [{ctx.guild.name}]({response.jump_url}).", color=await self.bot.get_embed_color(None))
embed = discord.Embed(title="Muted", description=f"You have been muted for {humanize.precisedelta(parsed_time)} 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: