cooldown-wk
v1.0.1
Published
Npm package for make cooldown system
Downloads
7
Maintainers
Readme
An npm to make your cooldown easier
const userModel = require('./models/User'); /* The database */
const cooldown = require('cooldown-wk'); /* The npm package */
let userGet = await userModel.findOne({ userId: message.author.id }); /* You need to use your own Database */
var number = 15000; /* 15 seconds to milliseconds */
if(user) {
if(cooldown.compare(user.userCooldown)) {
message.channel.send({ content: `You have to wait ${cooldown.time(user.userCooldown)} to use this command again.` });
} else {
user.userCooldown = cooldown.temporizator(number); /* Set cooldown time */
await user.save();
message.channel.send({ content: `You used the command!, Now you have to wait ${cooldown.timeResult(number)}` });
};
} else {
let newUser = new userModel({
userId: message.author.id,
userCooldown: 0
});
await newUser.save(); /* Create a new account */
message.channel.send({ content: 'Try again!' });
}