Don't track unknown command AT ALL

This commit is contained in:
Dragon Fire
2021-05-03 17:14:18 -04:00
parent 995ab23c81
commit 50a729bc6f
5 changed files with 13 additions and 3 deletions
+1
View File
@@ -357,6 +357,7 @@ client.on('error', err => client.logger.error(err.stack));
client.on('warn', warn => client.logger.warn(warn));
client.on('commandRun', async command => {
if (command.unknown) return;
client.logger.info(`[COMMAND] ${command.name} was used.`);
if (command.uses === undefined) return;
command.uses++;
+4 -1
View File
@@ -25,7 +25,10 @@ module.exports = class GroupLeaderboardCommand extends Command {
run(msg, { page }) {
const groups = this.client.registry.groups.map(group => {
const uses = group.commands.reduce((a, b) => a + (b.uses || 0), 0);
const uses = group.commands.reduce((a, b) => {
if (b.unknown || !b.uses) return a;
return a + b.uses;
}, 0);
return { uses, group };
});
const totalPages = Math.ceil(this.client.registry.groups.size / 10);
+3 -1
View File
@@ -21,7 +21,9 @@ module.exports = class LastRunCommand extends Command {
}
run(msg, { command }) {
if (command.lastRun === undefined) return msg.reply('That command\'s usage stats aren\'t being tracked.');
if (command.unknown || command.lastRun === undefined) {
return msg.reply('That command\'s usage stats aren\'t being tracked.');
}
if (!command.lastRun) return msg.reply(`The \`${command.name}\` command has never been run.`);
const displayTime = moment.utc(command.lastRun).format('MM/DD/YYYY h:mm A');
return msg.say(`The \`${command.name}\` command was last run on **${displayTime}**.`);
+3 -1
View File
@@ -21,7 +21,9 @@ module.exports = class UsesCommand extends Command {
}
run(msg, { command }) {
if (command.uses === undefined) return msg.reply('That command\'s usage stats aren\'t being tracked.');
if (command.unknown || command.uses === undefined) {
return msg.reply('That command\'s usage stats aren\'t being tracked.');
}
return msg.say(`The \`${command.name}\` command has been used **${formatNumber(command.uses)}** times.`);
}
};
+2
View File
@@ -213,6 +213,7 @@ module.exports = class XiaoClient extends CommandoClient {
exportCommandLeaderboard() {
let text = '{';
for (const command of this.registry.commands.values()) {
if (command.unknown) continue;
if (command.uses === undefined) continue;
text += `\n "${command.name}": ${command.uses},`;
}
@@ -245,6 +246,7 @@ module.exports = class XiaoClient extends CommandoClient {
exportLastRun() {
let text = '{';
for (const command of this.registry.commands.values()) {
if (command.unknown) continue;
if (command.lastRun === undefined) continue;
text += `\n "${command.name}": ${command.lastRun ? `"${command.lastRun.toISOString()}"` : null},`;
}