首页 > 解决方案 > The number of times users have used commands

问题描述

I need a script that will count how much the community has used all the bot commands in discord.js. One that will count from 1 to infinity.

I have such a script, and I don't know what to add to it so that the counter appears.

if (commandfile) {
   commandfile.run(client, message, args);
   console.log("Today, users have written some commands there.");
}

Please help me.

I use a translator because I don't speak English well. Excuse me.

标签: javascriptdiscord.js

解决方案


You could use a database, specifically quick.db

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

if (commandfile) {
  commandfile.run(client, message, args);
  db.add(`commandran_${message.guild.id}`, 1);
  let dbfetch = db.fetch(`commandran_${message.guild.id}`);
  console.log(`Today, users have ran ${dbfetch} commands`);
}

推荐阅读