From a617abea3a32a30f4e12493a387d9a0a672c9ae8 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 2 Apr 2020 19:12:46 +0200 Subject: [PATCH] executed command count and fixed the hardcoded channel --- event/listeners/commandstarted.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/event/listeners/commandstarted.js b/event/listeners/commandstarted.js index 0bb13e3..2f4965a 100644 --- a/event/listeners/commandstarted.js +++ b/event/listeners/commandstarted.js @@ -58,6 +58,7 @@ class commandStartedListener extends Listener { let uniqueGuild = []; let commands = {}; + let executedCommands = 0; report.forEach(e => { if (!uniqueGuild.includes(e.guild)) { @@ -69,6 +70,9 @@ class commandStartedListener extends Listener { } else { commands[e.command] = commands[e.command] + 1; } + + executedCommands++; + }); if ( !lastUpdate || ( today.getTime() - lastUpdate.getTime() ) > 30000 ) { @@ -86,22 +90,19 @@ class commandStartedListener extends Listener { .setColor('GREEN') .setTitle('Daily usage report!') .addField('Number of unique guild', uniqueGuild.length) - .addField('Number of command exectued', Object.keys(commands).length, true) + .addField('Number of command exectued', executedCommands, true) .addField('Most used command', `${getKeyByValue(commands, max)} (${max} times)`, true ) .addField('Least used command', `${getKeyByValue(commands, min)} (${min} times)`, true) .setFooter(`Bot usage as of ${today}`); - const channel = this.client.channels.resolve('586308815868395535'); + const channel = this.client.channels.resolve(dailyStats); channel.send(Embed); - - console.log(`Min value: ${min}, max value: ${max}\nLeast used command: ${getKeyByValue(commands, min)}, Most used command: ${getKeyByValue(commands, max)}`); - + uniqueGuild = []; commands = {}; report = []; - //this_is_where_you_would_reset_stuff() } } }