Skip to content
Advertisement

How to make a timed bool in discord.js

I want my bot to reply “Good morning” whenever someone says “good morning”, for example. I’ve got all that figured out, but now I wanted to put a timer onto it and it is getting a bit more complicated. I want the timer to be for absolutely everyone on the server. If anyone says good morning then let’s make the bot wait 3 seconds, for example. I’ve tried a couple different solutions but none work so I would see if I could get any help here.

JavaScript

I have also tried this other solution that I found online. I got “Syntax error: Unexpected Identifier” for this one on line 3 even though line 5 is very similar:

JavaScript

Thank you for all the help in advance.

Advertisement

Answer

It seems like you are wanting a global cooldown for this command.

This can easily be done by setting the value to false immediately, then 3000ms later turn the value back to true

JavaScript
Advertisement