Python 如何修复discord.py中cogs中的asyncio.sleep错误

Python 如何修复discord.py中cogs中的asyncio.sleep错误,python,discord,discord.py,bots,Python,Discord,Discord.py,Bots,因此,基本上这是一个cog文件夹,其中mute命令在特定时间向成员添加mute角色。我制作了一个函数converts,它将时间转换为秒,因为asyncio.sleep()需要秒。但是我得到了一个错误:-TypeError:“错误显示在哪一行?在await asyncio.sleep(time)line中,您可以共享整个回溯吗? class Mod(commands.Cog): def __init__(self,client:commands.Bot): self.cli

因此,基本上这是一个cog文件夹,其中mute命令在特定时间向成员添加mute角色。我制作了一个函数
converts
,它将时间转换为秒,因为
asyncio.sleep()
需要秒。但是我得到了一个错误:-
TypeError:“错误显示在哪一行?在
await asyncio.sleep(time)
line中,您可以共享整个回溯吗?
class Mod(commands.Cog):
    def __init__(self,client:commands.Bot):
        self.client = client
    def converts(time):
        pos = ["s","m","h","d","y"]

        time_dict = {"s" : 1, "m" : 60, "h" : 3600 , "d" : 3600*24, "y" : 86400*365}

        unit = time[-1]

        if unit not in pos:
            return -1
        try:
            val = int(time[:-1])
        except:
            return -2
        return val * time_dict[unit]
    @commands.command()
    async def mute(self,ctx, member: discord.Member,toime = None,*,reason = None): #i gave the input like '-mute @abc 10s'
        guild = ctx.guild
        mutedRole = discord.utils.get(guild.roles, name="Muted")
        if ctx.author.guild_permissions.administrator:
            if member == ctx.guild.me:
                await ctx.send("You can mute me loser")
            
            else:
                if member.top_role.position >= ctx.guild.me.top_role.position:
                    await ctx.send("Uhh uh kinda awkward but that person is higher than me ;-;")
                else:
                    if ctx.author.top_role.position <= member.top_role.position:
                        await ctx.send("I cant do dat")
                    else:
                        if not mutedRole:
                            await ctx.send("A muted role dont exist u can make one by using mutedrole command")
                        if mutedRole in member.roles:
                            await ctx.send("Hes already muted what a loser")
                            
                        else:
                            if toime == None:
                                await member.add_roles(mutedRole,reason=reason)
                                await ctx.send(f"muted {member.mention} {reason}")
                            else:
                                time = Mod.converts(toime)
                                await member.add_roles(mutedRole)
                                em = discord.Embed(description = f"<a:muted:837357553137745950> Muted {member.name} for {toime}",color = discord.Colour.green())
                                a = await ctx.send(embed = em)
                                await a.add_reaction("<a:muted:837357553137745950>")
                                await a.add_reaction("<:sad_cat:837529216983105566>")
                                await asyncio.sleep(time)
                                await member.remove_roles(mutedRole)

        else:
            await ctx.send("U not a admin bruh")

def setup(client : commands.Bot):
    client.add_cog(Mod(client))
    print("Mod is loaded")