如何计算一个命令被使用的次数[discord.js]

如何计算一个命令被使用的次数[discord.js],discord,discord.js,quick.db,Discord,Discord.js,Quick.db,简单地说,当人们使用教程!ping命令我想数一数有多少次,然后在聊天中显示出来。就像“ping已经被使用了很多次”一样,我发现一些东西在谈论quick.db,但仍然不知道很多。目前,消息显示为[这已经被使用了很多次!!!] module.exports = { name: 'ping', description: 'Ping!', execute (message, args, ) { const db = require('quick.db') var times

简单地说,当人们使用教程!ping命令我想数一数有多少次,然后在聊天中显示出来。就像“ping已经被使用了很多次”一样,我发现一些东西在谈论quick.db,但仍然不知道很多。目前,消息显示为[这已经被使用了很多次!!!]

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

正确的解决方案很简单。就这么做吧

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的说明。

如果您有任何问题,请告诉我^-^!顺便说一句,如果你能将我的答案标记为一个解决方案,那就太好了。我还有一件事我有问题,那就是它们是私有消息还是我需要做另一个堆栈溢出问题堆栈溢出上没有私有消息。你得再问一个问题