使用asyncio与nextcord时遇‘coroutine 'sleep' was never awaited’错误求助
解决"coroutine 'sleep' was never awaited"错误(Nextcord框架)
错误原因很明确:asyncio.sleep()是异步协程函数,调用时必须用await关键字等待它执行完毕,否则Python会判定这个协程未被处理,抛出你看到的错误。
直接修改代码中的这一行:
将
asyncio.sleep(3)
替换为
await asyncio.sleep(3)
修改后的完整代码:
embed=nextcord.Embed(title=catName, url=catLink, color=0xcc7314) embed.set_image(url=catURL) embed.set_footer(text=f"Cat image posted on r/{catSub} by {catPoster}") finding=nextcord.Embed(description=f"<a:loading:1018351524394569752> Finding `cat` image", color=0xcc7314) loading = await ctx.reply(embed=finding, allowed_mentions=pingManager) await asyncio.sleep(3) await loading.edit(embed=embed)
内容的提问来源于stack exchange,提问作者Pure.
相关产品推荐
相关产品推荐

