0

I'm coding in Python and started coding recently. I created super simple clockwork mini machine in Python:

if message.content.startswith("Clock"):
    await message.channel.send("3")
    time.sleep(1)
    await message.channel.send("2")
    time.sleep(1)
    await message.channel.send("1")

But now I want to make the bot delete previous message automatically, so it would look like single message turning into 3, 2, 1

Sincere thanks,

Aaron

Aaron
  • 197
  • 2
  • 8

2 Answers2

1

You can use the delete_after parameter,

 message.channel.send("3", delete_after=1)

This will delete the message after 1 second, without blocking your code.

References:-

Note: Don't use time.sleep it blocks your entire code. Source

Ceres
  • 2,200
  • 1
  • 6
  • 22
0

You could do it like this

if message.content.startswith("Clock"):
    MessageOne = await message.channel.send("3")
    time.sleep(1)
    await MessageOne.delete()
    MessageTwo = await message.channel.send("2")
    time.sleep(1)
    await MessageTwo.delete()
    MessageThree = await message.channel.send("1")
    time.sleep(1)
    await MessageThree.delete()
FreeMarket
  • 11
  • 1
  • 1