所以如果我有一个像这样的长命令:
@bot.command(pass_context=True)
async def longCommand(ctx):
#typing status
sleep(10)
bot.say("Done!")
不幸的是,在文档或此处未找到任何内容。
最佳答案
编辑:较新版本的 discord 要求您使用新语法:
@bot.command()
async def mycommand(ctx):
async with ctx.typing():
# do expensive stuff here
await asyncio.sleep(10)
await ctx.send('done!')
旧版本使用这个:
@bot.command(pass_context=True)
async def longCommand(ctx):
await bot.send_typing(ctx.channel)
await asyncio.sleep(10)
await bot.say("Done!")
记得在每次异步调用协程时使用await
。
关于python - 如何让 Discord 机器人显示 "Bot is typing ..."状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51252714/