-1

只是当人们使用教程 !ping 命令时,我想计算多少次并将其显示在聊天中。就像“ping 已经被使用过很多次”一样,我发现了一些关于 quick.db 的内容,但仍然不太了解。目前,消息显示为 [This has been used This NaN times!!!]

module.exports = {
  name: 'ping',
  description: 'Ping!',
  execute (message, args, ) {
    const db = require('quick.db')
    var times = []
    db.set('times', {hello: 'hi'})
    db.add('times.used', 1)
      let timesused = times.used + 1;
      message.reply('pong');
      message.channel.send(`This has been used This ${timesused} times!!!`);
  },
};
4

1 回答 1

0

您尝试做的事情的正确解决方案很简单。就这样做吧。

const db = require('quick.db');

module.exports = {
  name: 'ping',
  description: 'Ping!',
  execute (message, args) {
    db.add('times.ping', 1); // Adding an amount of one to the countor for the ping command

    const timesUsed = db.get('times.ping'); // Getting the amount of uses 

    message.reply('pong!');
    message.channel.send('This command has been used '+timesUsed+' times!');
  },
};

如需更好的解释,请阅读 Quick.db 的文档

于 2020-12-22T23:18:26.893 回答