How do I make discord.py wait

Viewed 2072

How can I make discord.py send a messages, then wait a little bit, and send another message.

Right now, this is my command

#b is the client
b.command()
async def message(ctx)
  await ctx.send(First Message)
  await ctx.send(Second Message after 5 Seconds)
2 Answers

You can use await asyncio.sleep(seconds). Also, your code has a few typo errors.

You should add @ at the beginning of b.command() and also after async def message(ctx), you need to add :.

import asyncio
@b.command()
async def message(ctx):
    await ctx.send('First message')
    await asyncio.sleep(5)
    await ctx.send('Second message after 5 seconds')

You can also use import time heres an example:

import time

@bot.command()
async def Hello(ctx):
 time.sleep(5)
 await ctx.send("Hello1")
 time.sleep(5)
 await ctx.send("Hello2")
Related