From 855daefa4d0333c508ff328201eb0f7b3ea1cf3d Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 8 Jul 2021 12:06:31 +0200 Subject: [PATCH] Move guild count into own function --- commands/botinfo.js | 7 ++----- util/getGuildCount.js | 8 ++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 util/getGuildCount.js diff --git a/commands/botinfo.js b/commands/botinfo.js index 6393a7f..80e8532 100644 --- a/commands/botinfo.js +++ b/commands/botinfo.js @@ -1,5 +1,6 @@ const Discord = require('discord.js'); const getCreationDate = require('../util/getCreationDate'); +const getGuildCount = require('../util/getGuildCount'); @@ -7,11 +8,7 @@ module.exports = { name: 'botinfo', description: 'Shows information about the bot', execute({message, client, prefix}) { - let guildCount = 0; - client.guilds.cache.each(() => { - guildCount++ - }); - + let guildCount = getGuildCount(client) const embed = new Discord.MessageEmbed() .setColor(15780145) .setTitle("Information about bot") diff --git a/util/getGuildCount.js b/util/getGuildCount.js new file mode 100644 index 0000000..5fff1e5 --- /dev/null +++ b/util/getGuildCount.js @@ -0,0 +1,8 @@ +module.exports = function(client){ + let guildCount = 0; + client.guilds.cache.each(() => { + guildCount++ + }); + + return guildCount; +} \ No newline at end of file