1
votes

I'm new to the field of discord bots, I had an idea and it's that, I want to make my bot show "bot is typing..." status before the bot send any messages. I simply want it to looks like real typing you know? And I guess that will look better than just sending the messages immediately.

BTW, I'm using Discord.py Rewrite

Thanks for your help in advance!


example for what I want the bot to do.

1

1 Answers

2
votes

Use async with channel.typing()

If you are unfamiliar with the with statement, it is a way of wrapping a codeblock in a statement, which does something at the start of the code block and the end of the codeblock.

Example:

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')