UNPKG

command-cooldown

Version:

a simple (discord bots anything really) cooldown for commands made using quick.db

70 lines (53 loc) 2.19 kB
# command-cooldown a simple (discord bots anything really) cooldown for commands made using quick.db # V 1.0.0 is Here with new changes * do i need to tell you ? (fixed some issues again again again). * fixed some issues again lol. * added spam protection if you want lol, "<cd>.res.spam". * added multi cooldowns for every command option. * Fixed some issues with the database. ## Features * Easy to use. * Fast. * You can change everything. ## Requirements * quick.db , for saving cooldowns in order to avoid cooldowns being removed before it's timer runs out. ## Changelog See [Changelog](CHANGELOG.md) ! ### Supports : * node.js ## Configuration * example with discord.js * this example allows you to make a cooldown for each command individually if you do not want this do "cmdCD.addCoolDown(message.author.id, 5000);" and "await cmdCD.checkCoolDown(message.author.id)" ``` const cmdCD = require('command-cooldown'); client.on('message',async message => { if (message.content == "ping") { let cd = await cmdCD.checkCoolDown(message.author.id, "cmd-ping"); if (cd.res.spam) return "this user spams this command, i will not do any thing in order to not get rate limted"; if (!cd.res.ready) return message.reply(`Reamaining ${(cd.res.rem / 1000).toFixed(1)}s`); message.reply(`My Ping is : ( ${client.ws.ping}Ms )`); cmdCD.addCoolDown(message.author.id, 5000, "cmd-ping"); }; }); ``` # Response it will output remaning time in ms so you could do anything :) ``` { ready : Boolean // whether the command is ready to user or not rem : Timestapms //remaining time cmd : String // cooldown's command name spam : Boolean // if the user is spamming the cooldown } ``` ### Options These are the keys in the options you can pass. - `ID`, `type : string or number, the cooldown author id` - `5000` , `type : Timestamp, the cooldown duration in ms`. - `"cmd-name"` , `type : String, the cooldown command name this helps to add multi cooldowns *NOT REQUIERD*`. ``` cmdCD.addCoolDown(ID, 5000, "cmd-name"); ^^ ^^^^ * ^ = required ```