-1

it say TypeError: object NoneType can't be used in 'await' expression and whene i delete await it not work

@bot.event
async def on_message_delete(message):
     snipe_message_author[message.channel.id] = message.author
     snipe_message_content[message.channel.id] = message.content
     await time.sleep(2) # <=== here 
     del snipe_message_author[message.channel.id]
     del snipe_message_content[message.channel.id]
  • In so many words `time.sleep()` runs there and then, and returns `None` to `await`. The mechanism for "sleeping" in async code looks quite different. – tripleee Dec 09 '22 at 17:39

1 Answers1

0

Instead of time.sleep(), you need to use asyncio.sleep()

@bot.event
async def on_message_delete(message): 
     snipe_message_author[message.channel.id] = message.author
     snipe_message_content[message.channel.id] = message.content
     await asyncio.sleep(2)
     del snipe_message_author[message.channel.id]
     del snipe_message_content[message.channel.id]

You also need to import asyncio by placing import asyncio at the top of your code. You can also use from asyncio import sleep and use sleep() instead of asyncio.sleep() but this is not recommended as you might have another sleep() function.

MrHDumpty
  • 56
  • 1
  • 10
nigh_anxiety
  • 1,428
  • 2
  • 4
  • 12