Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i make my discord bot shows in chat like "Bot is typing"

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.

like image 790
The Prince Avatar asked Sep 06 '25 03:09

The Prince


1 Answers

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')
like image 67
chluebi Avatar answered Sep 07 '25 16:09

chluebi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!