'Discord.py - mute message with timer

i have an issue with my code

which when use !mute command to @username 9s it's muted for 9 seconds but when inputted !mute @username 32s it only muted 3 seconds (or first digit number are inputted) which it should 32 seconds

another ex: !mute @username 12m = muted for 1 minutes (first digit number are inputted to mute command)

here's my code:

@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, time, reason=None):
    desctime = time
    guild = ctx.guild
    mutedRole = discord.utils.get(guild.roles, name="Muted")
    time_convert = {"s":1, "m":60, "h":3600, "d":86400, "w":604800, "mo":18144000, "y":31536000}
    tempmute= int(time[0]) * time_convert[time[-1]]
    if not mutedRole:
        mutedRole = await guild.create_role(name="Muted")
        for channel in guild.channels:
            await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
    embed = discord.Embed(title="muted", description=f"{member.mention} was muted   for {desctime} ", colour=discord.Colour.light_gray())
    embed.add_field(name="reason:", value=reason, inline=True)
    await ctx.send(embed=embed)
    await member.add_roles(mutedRole, reason=reason)
    await asyncio.sleep(tempmute)
    await member.send(f" you have been muted from: {guild.name} reason: {reason}")
    await member.remove_roles(mutedRole)

    


Solution 1:[1]

You are doing int(time[0]). Try int(time[:-1])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RedstoneRadiant