
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
djs-cooldown
Advanced tools
djs-cooldown is a Node.js package to add cooldown for everything you want using MongoDB, but the main purpose of this package is for Discord BOT commands made by discord.js
Node.js 16.11.0 or newer is required.
# These are common JS runtime environment that you may use
# Just choose one that suitable for you
npm install djs-cooldown
yarn add djs-cooldown
pnpm add djs-cooldown
bun add djs-cooldown
const { DJS_Cooldown } = require("djs-cooldown");
const djs_cooldown = new DJS_Cooldown({
connection: "mongodb+srv://...", // your MongoDB Connection
message: "Connected to MongoDB Successfully",
});
connection: String - The MongoDB connection string,
message: String - The success message when connected to MongoDB.
disconnect: String - The success message when disconnected from MongoDB.
Set and check cooldown when user uses a command
client.on("message", async (message) => {
// example Command Handler
let cmd = client.getCommand(message.content);
if (!cmd) return;
// Cooldown System
let isEnded = await djs_cooldown.checkCooldown({
identity: message.author.id,
name: `text/${cmd.name}`,
});
if (!isEnded) return message.channel.send(`You are on cooldown!`);
// cooldown not found or ended
cmd.run(...);
// set new cooldown
await djs_cooldown.set({
identity: message.author.id,
name: `text/${cmd.name}`,
cooldown: 15 * 1000, // 15 seconds in ms
usedAt: Date.now()
}, function(error, message) {
if(error) console.error(error);
});
});
await djs_cooldown.setDB("mongodb+srv://..."); // new connetion URL
// You need to re-connect to MongoDB to change URL
await djs_cooldown.disconnect();
await djs_cooldown.connect();
// or simple way
await djs_cooldown.reconnect();
// shorter
await djs_cooldown.setDB("mongodb+srv://...", true); // "true" here means turn on automatically reconnect when reset connection URL
// Refresh Database connection state (avoid package required connect another time to use)
await djs_cooldown.refreshDB(); // Will log again if already connected
// Set new cooldown for user
await djs_cooldown.set({
identity: "1234812",
name: "somethingherer??",
cooldown: 15 * 1000,
usedAt: Date.now(),
});
// Remove a created cooldown if you think something went wrong
await djs_cooldown.remove({
identity: "1234812",
name: "somethingherer??",
});
await djs_cooldown.checkCooldown({
identity: "1234812",
name: "somethingherer??",
});
// > true
// Is the cooldown ended? (true/false)
await djs_cooldown.timeLeft({
identity: "11111111111",
name: "somethinghereig?",
});
// > 123412
// Time left in milliseconds
timeLeft < 0, output will be 0
data-Object: Provide data to do job
identity-String: User ID / Guild ID / etc...name-String: Cooldown for "name"cooldown-Number: Cooldown time (in ms)usedAt-Number | String: Timestamp when the cooldown was used
callback-Function | null(optional): Callback when code complete jobs. Return 2/3 variables:
error-Boolean: Check if error occursmessage-String: Return messagedata-Object | null(depends on purpose): Return collected data (used for some functions)
Some functions do not required all fields, you can provide only what needed.
If you have any problems or want to report some bugs, let us know
FAQs
Discord.JS BOT | Add cooldown for your BOT's commands
We found that djs-cooldown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.