Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let ms = require('ms')
  2. let db = require('quick.db')
  3. //check if there is cooldown
  4.     const timeout = 604800000; // 7 days in milliseconds, change to the desired cooldown time, in milliseconds
  5.     const cooldown = await db.fetch(`cooldown_Command-Name_${message.guild.id}_${message.author.id}`);
  6.  
  7.     if (cooldown !== null && timeout - (Date.now() - cooldown) > 0) {
  8.         const time = ms(timeout - (Date.now() - cooldown));
  9.         message.channel.send(`Sorry you must wait **${time.days}d ${time.hours}h ${time.minutes}m ${time.seconds}s** before using this command again!`);
  10.     } else {
  11. //code here that runs if there is no cooldown
  12.  
  13. // code put after no cooldown code, to set the cooldown
  14.         db.set(`cooldown_Command-Name_${message.guild.id}_${message.author.id}`, Date.now());
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement