You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 21:15:47