1

I am using an on_message function in discord.py and after recieving the message the bot responds: await message.channel.send("response") but this happens instantly, is there any way for me to delay this reponse for a couple of seconds?

1 Answer 1

1

You can use await asyncio.sleep(seconds_to_sleep) which adds async-friendly delay to your bot actions

import asyncio

# ... then in a cog
    @commands.Cog.listener()
    async def on_message(self, message: discord.Message):
        if message.author == self.bot.user:
            return
        await asyncio.sleep(5)
        await message.channel.send("response")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.