Ask coding questions

← Back to all posts
How do you make a cooldown on a command in python
Botonkoolaidon (1)

i need help How do you make a cooldown on a command in python

Comments
hotnewtop
InvisibleOne (2990)

Well, you could do this if say, you don't want a command used more then once per ten seconds

import time

if message.startswith('command'): #whatever
  if time.time() >= timeLock:
    #this command can be ran
   timeLock = time.time() + 10000 #reset the time lock
  else:
   #this command cannot be ran

Of course, this is pretty basic but it's the idea that counts I guess.
@cuber1515 you wanted to be tagged.

cuber1515 (59)

If any one knows how, can you @ me too because that's something I need to know too.