BlackKnight683

Better Cooldown System [BCFD]

Jan 14th, 2022
899
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $eval
  2.  
  3. var time = 10 //timeout in seconds
  4.  
  5. var msg = "$message";
  6. var filter = msg.split(" ", 1);
  7. var CooldownTime = time; //Seconds
  8. var Table = (Table == null) ? {} : Table;
  9. var Command = filter + $ID;
  10. var reply;
  11.  
  12. if(!Table[Command]) Table[Command] = {};
  13. Table[Command].Time = new Date().getTime();
  14. if(!Table[Command].TimeRemaining) Table[Command].TimeRemaining = 0;
  15.  
  16.  
  17. if(Table[Command].Time >= Table[Command].TimeRemaining) {
  18. Table[Command].TimeRemaining = (CooldownTime * 1000 + new Date().getTime());
  19.  
  20.  //Remove $eval, $halt And $get from your code\\
  21.  //Paste code below\\
  22.  //Variable reply is the message sent\\
  23.  reply = "pong!"
  24.  
  25. } else {
  26.  
  27. reply = "You can use this command again <t:" + Math.round((new Date().getTime() + (Table[Command].TimeRemaining - Table[Command].Time)) / 1000) + ":R>";
  28.  
  29. }
  30. $halt
  31. $get(reply)
RAW Paste Data