From b280981e1c2fcdac328530854657da2cdc856b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sun, 5 Sep 2021 06:15:54 +0300 Subject: [PATCH] Updated statistics command --- src/client/commands/statistics.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/client/commands/statistics.js b/src/client/commands/statistics.js index 02886fe..b96ef04 100644 --- a/src/client/commands/statistics.js +++ b/src/client/commands/statistics.js @@ -9,6 +9,7 @@ module.exports = { let message = {}; let stations = client.stations; let currentGuild = client.datastore.getEntry(interaction.guild.id); + let global = client.datastore.getEntry("global"); let statistics = ""; if(!client.stations) { @@ -21,9 +22,13 @@ module.exports = { } else { Object.keys(stations).forEach(function(station) { if(currentGuild.statistics[stations[station].name] && currentGuild.statistics[stations[station].name].time && parseInt(currentGuild.statistics[stations[station].name].time) > 0 && currentGuild.statistics[stations[station].name].used && parseInt(currentGuild.statistics[stations[station].name].used) > 0){ - statistics += `**${parseInt(station) + 1}** ` + stations[station].name + " \n"; - statistics += "Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + "\n"; - statistics += "Used: " + currentGuild.statistics[stations[station].name].used + "\n"; + statistics += `**${parseInt(station) + 1}. ` + stations[station].name + "** \n"; + if(global && global.statistics[stations[station].name] && global.statistics[stations[station].name].time && parseInt(global.statistics[stations[station].name].time) > 0 && global.statistics[stations[station].name].used && parseInt(global.statistics[stations[station].name].used) > 0){ + statistics += "Guild – Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + " (" + ((currentGuild.statistics[stations[station].name].time / global.statistics[stations[station].name].time) * 100) + "%" + ")" + " / " + "Used: " + currentGuild.statistics[stations[station].name].used + " (" + ((currentGuild.statistics[stations[station].name].used / global.statistics[stations[station].name].used) * 100) + "%" + ")" + "\n"; + statistics += "Global – Time: " + client.funcs.msToTime(global.statistics[stations[station].name].time) + " / " + "Used: " + global.statistics[stations[station].name].used + "\n\n"; + } else { + statistics += "Time: " + client.funcs.msToTime(currentGuild.statistics[stations[station].name].time) + " / " + "Used: " + currentGuild.statistics[stations[station].name].used + "\n\n"; + } } }); }