From 2ed7f28f99ab437eec3076a333f087ab5c9f6595 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Sun, 4 Apr 2021 12:08:07 -0500 Subject: [PATCH] Use await to fix undefined server count --- bot.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bot.js b/bot.js index c62fc60..20c6764 100644 --- a/bot.js +++ b/bot.js @@ -122,17 +122,17 @@ client.on("message", async message => { async function aboutBot(message) { const uptimeDays = client.uptime / 86400000; - let guildCount; - client.shard.fetchClientValues('guilds.cache.size') + let serverCount; + await client.shard.fetchClientValues('guilds.cache.size') .then(results => { - guildCount = results.reduce((acc, guildCount) => acc + guildCount, 0); + serverCount = results.reduce((acc, guildCount) => acc + guildCount); }) .catch(console.error); const aboutBotEmbed = new Discord.MessageEmbed() .setTitle("About me!") .setURL(`https://adat.link/awesomemod`) .setAuthor(client.user.tag, client.user.avatarURL()) - .addField(`Servers`, guildCount, true) + .addField(`Servers`, `${serverCount}`, true) .addField(`Uptime`, `${uptimeDays.toFixed(1)} days`, true) .addField(`Invite Link`, `Click the title to add this bot to your server!`) .setFooter(`Client ID: ${client.user.id}`)