我如何让我的 discord 机器人在聊天中显示为 "Bot is typing"
How do i make my discord bot shows in chat like "Bot is typing"
我是 discord 机器人领域的新手,我有一个想法,那就是,我想让我的机器人在发送任何消息之前显示 "bot is typing..." 状态。
我只是想让它看起来像真正的打字,你知道吗?而且我想这比立即发送消息看起来更好。
顺便说一句,我正在使用 Discord.py Rewrite
提前感谢您的帮助!
example for what I want the bot to do.
如果您不熟悉 with
语句,它是一种将代码块包装在语句中的方法,它在代码块的开头和代码块的结尾执行某些操作。
示例:
import asyncio
async def on_message(message):
if message.startswith('ping'):
async with message.channel.typing():
await asyncio.sleep(1)
await message.channel.send('pong')
我是 discord 机器人领域的新手,我有一个想法,那就是,我想让我的机器人在发送任何消息之前显示 "bot is typing..." 状态。 我只是想让它看起来像真正的打字,你知道吗?而且我想这比立即发送消息看起来更好。
顺便说一句,我正在使用 Discord.py Rewrite
提前感谢您的帮助!
example for what I want the bot to do.
如果您不熟悉 with
语句,它是一种将代码块包装在语句中的方法,它在代码块的开头和代码块的结尾执行某些操作。
示例:
import asyncio
async def on_message(message):
if message.startswith('ping'):
async with message.channel.typing():
await asyncio.sleep(1)
await message.channel.send('pong')