From 94344bbecdc4d4d5c194b505bf9ab74e2ea4c660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Tue, 31 Mar 2020 10:37:47 +0300 Subject: [PATCH] Fixed statistics command when guild has empty statistics (part 2) --- commands/statistics.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/commands/statistics.js b/commands/statistics.js index 35268a3..e8c585e 100644 --- a/commands/statistics.js +++ b/commands/statistics.js @@ -11,7 +11,9 @@ module.exports = { let statistics; let i = 0; - if(currentGuild.statistics){ + if(!currentGuild || currentGuild && !currentGuild.statistics){ + statistics = "You have not listened any radio station"; + } else { Object.keys(client.stations).forEach(function(station) { if(currentGuild.statistics[stations[station].name]){ if(i > 0){ @@ -28,10 +30,6 @@ module.exports = { }); } - if(!statistics){ - statistics = "You have not listened any radio station"; - } - const embed = new Discord.MessageEmbed() .setTitle(client.messages.statisticsTitle) .setThumbnail("https://cdn.discordapp.com/emojis/" + client.messageEmojis["list"].replace(/[^0-9]+/g, ''))