diff --git a/src/structure/components/commands/developer/Stats.js b/src/structure/components/commands/developer/Stats.js index 9ebc1a5..a12dd9d 100644 --- a/src/structure/components/commands/developer/Stats.js +++ b/src/structure/components/commands/developer/Stats.js @@ -104,16 +104,29 @@ class StatsCommand extends SlashCommand { }; //Command statistics - probably expand this further - const { commands } = this.client.registry; - const commandValues = { - invokes: commands.reduce((acc, cmd) => acc + cmd._invokes.success + cmd._invokes.fail, 0), - success: commands.reduce((acc, cmd) => acc + cmd._invokes.success, 0), - fail: commands.reduce((acc, cmd) => acc + cmd._invokes.fail, 0), - successExecTime: Math.round(commands.reduce((acc, cmd) => acc + cmd._invokes.successTime, 0) / commands.size), - failExecTime: Math.round(commands.reduce((acc, cmd) => acc + cmd._invokes.failTime, 0) / commands.size), + const commandsEval = (client) => { + const { commands } = client.registry; + const values = { + invokes: commands.reduce((acc, cmd) => acc + cmd._invokes.success + cmd._invokes.fail, 0), + success: commands.reduce((acc, cmd) => acc + cmd._invokes.success, 0), + fail: commands.reduce((acc, cmd) => acc + cmd._invokes.fail, 0), + successExecTime: Math.round(commands.reduce((acc, cmd) => acc + cmd._invokes.successTime, 0) / commands.size), + failExecTime: Math.round(commands.reduce((acc, cmd) => acc + cmd._invokes.failTime, 0) / commands.size), + }; + values.avgTime = Math.round((values.successExecTime + values.failExecTime) / 2); + return values; }; - commandValues.avgTime = Math.round((commandValues.successExecTime + commandValues.failExecTime) / 2); + const commandValues = {}; + const commandResult = await shard.broadcastEval(commandsEval).catch((error) => this.client.logger.error(error.stack || error)); + // commandValues.avgTime = Math.round((commandValues.successExecTime + commandValues.failExecTime) / 2); + for (const result of commandResult) { + for (const key of Object.keys(result)) { + if(!commandValues[key]) commandValues[key] = 0; + commandValues[key] += result[key]; + } + } + commandValues.avgTime /= commandResult.length; const embed = { title: invoker.format('COMMAND_STATS_TITLE', {