猿问

如何使机器人显示“正在输入……”状态?

所以,如果我有一个很长的命令,像这样:


@bot.command(pass_context=True)

async def longCommand(ctx):

   #typing status

   sleep(10)

   bot.say("Done!")

不幸的是,在文档中或此处未找到任何内容。


慕田峪7331174
浏览 206回答 3
3回答

MMTTMM

如果使用rewrite分支,则所有都Messageable具有一个typing允许您无限期键入的上下文管理器和一个trigger_typing可在几秒钟内显示键入消息的协程。@bot.command()async def longCommand(ctx):   async with ctx.typing():        await sleep(10)   await ctx.send("Done!")
随时随地看视频慕课网APP

相关分类

Python
我要回答