0
  @commands.command(name = "mute")
  @commands.has_permissions(administrator = True)
  async def mute(self, ctx, member: discord.Member, reason = None, duration = 5, *, unit = None):

    mute_embed = discord.Embed(name = "Muted", description = "Disables the user to type messages untill unmuted", color = discord.Color.green())
    mute_embed.set_author(name = f"{ctx.author.display_name}", icon_url = f"{ctx.author.avatar_url}")
    mute_embed.add_field(name = "Mute", value = f"{ctx.author} successfully muted {member} for {reason} for {duration}{unit}")
    mute_embed.set_footer(text = f"Information requested by: {ctx.author.display_name}")

    if reason == None:
      reason = "No reason specified" 

    guild = ctx.guild
    Muterole = discord.utils.get(guild.roles, name = "Muted")

    if not Muterole:
      Muterole = await guild.create_role(name = "Muted")

    for channel in guild.channels:
      await channel.set_permissions(Muterole, speak = False, send_messages = False)
      
    await member.add_roles(Muterole)
    await ctx.send(embed = mute_embed)

    if unit == "s":
      wait = 1 * duration
      wait(wait)
    elif unit == "m":
      wait = 60 * duration
      wait(wait)
    elif unit == "h":
      wait = 3600 * duration
      wait(wait)
    elif unit == "d":
      wait = 86400 * duration
      wait(wait)
    elif unit == "w":
      wait = 604800 * duration
      wait(wait)

    unmuted_embed = discord.Embed("Unmuted", description = "Enables the user to type after getting muted", color = discord.Color.green())
    unmute_embed.set_author(name = f"{ctx.author.display_name}", icon_url = f"{ctx.author.avatar_url}")
    unmute_embed.add_field(name = "Unmute", value = f"{ctx.author} successfully unmuted {member} for {reason}")
    unmute_embed.set_footer(text = f"Information requested by: {ctx.author.display_name}")
    await member.remove_roles(Muterole)
    await ctx.send(embed = unmute_embed)
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 2
    you defined the default value as `5`. The error is due to the actual value that was passed when someone invoked the command. – Barmar Feb 02 '22 at 04:50
  • 2
    What value did you specify for the duration when invoking the command? – Barmar Feb 02 '22 at 04:51

0 Answers0