How to make add cooldowns to a command in discord.js
// First, this must be at the top level of your code, **NOT** in any event!
const talkedRecently = new Set();
if (talkedRecently.has(msg.author.id)) {
msg.channel.send("Wait 1 minute before getting typing this again. - " + msg.author);
} else {
// the user can type the command ... your command code goes here :)
// Adds the user to the set so that they can't talk for a minute
talkedRecently.add(msg.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(msg.author.id);
}, 60000);
}
Also in JavaScript:
- iframe set value on input outside js
- how to use a function from another file in javascript
- nodejs make directory
- sort by ascending javascript
- copy to clipboard angular
- drupal 8 render node programmatically
- display form input on console jquery
- js obj getting count of properties
- how to conver time format to 12 hours in javascript
- html call javascript function with input value
- javascript var dump
- javascript array vs object
- status discored jks
- chartjs line and bar order
- react route multiple components
- javascript greater than or equal to
- introduction to meteor.js development quiz answers
- reduce javascript acc became numeber insted array
- js object length
- react hook form rating material ui
- javascript variable object
- how to change the background color in jquery
- javascript remove underscore and capitalize
- javascript is valid email