cooldown-wk

1.0.1 • Public • Published

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!' });
}

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i cooldown-wk

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.31 kB

    Total Files

    3

    Last publish

    Collaborators

    • woksdev