V
V
Vlad_Lop122020-09-06 15:10:50
Python
Vlad_Lop12, 2020-09-06 15:10:50

How to make cd?

I wanted to make a cooldown through asyncio.slepp, but something did not work out. Please advise how it can be implemented. Purpose: If 1 participant has registered 'Hello', then the bot sends him the text 'Hello to you too', after which n number of times must not respond to the hello list. (meaning fall asleep)

hello = ['Привет', 'Хай']

@client.event
async def on_message(message):
  m = message.content.lower()
  if message.author == client.user:
        return

  if m in hello:
    await message.channel.send('И тебе привет!')
    await asyncio.sleep(60)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bbkmzzzz, 2020-09-06
@Vlad_Lop12

For example, save the time of the event (message reception), when the next one occurs, calculate the time difference and perform / do not perform actions

S
SerjLore, 2020-09-06
@SerjLore

hello = ['Hi', 'Hi']
@client.event
async def on_message(message):
m = message.content.lower()
if message.author == client.user:
return
If you do message.content.lower () then in the list indicate the message in small letters, otherwise the bot will not send anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question