From 5aba35502b36c183c9c64d4dc4fd032ba2098a00 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sat, 7 Mar 2020 13:42:47 +0100 Subject: [PATCH] Fix guild create and delete --- event/listeners/guildCreate.js | 5 +++-- event/listeners/guildDelete.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/event/listeners/guildCreate.js b/event/listeners/guildCreate.js index 7e440003..ae4b4a6c 100644 --- a/event/listeners/guildCreate.js +++ b/event/listeners/guildCreate.js @@ -13,6 +13,7 @@ class guildCreateListener extends Listener { async exec(guild) { console.log(`${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}`); const channel = this.client.channels.resolve(statsChannel); + let botCount = guild.members.cache.filter(member => member.user.bot).size; const addEmbed = this.client.util.embed() .setColor('#52e80d') .setTitle('New boiz in town') @@ -21,8 +22,8 @@ class guildCreateListener extends Listener { .addField('Guild name', guild.name, true) .addField('Guild ID', guild.id, true) .addField('Total number of members', guild.memberCount, true) - .addField('Number of users', guild.members.filter(member => !member.user.bot).size, true) - .addField('Number of bots', guild.members.filter(member => member.user.bot).size, true) + .addField('Number of users', guild.memberCount - botCount, true) + .addField('Number of bots', botCount, true) .addField('Owner', guild.owner.user.username, true) .addField('Owner ID', guild.owner.id, true) .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`) diff --git a/event/listeners/guildDelete.js b/event/listeners/guildDelete.js index 209cd324..3ce18bcb 100644 --- a/event/listeners/guildDelete.js +++ b/event/listeners/guildDelete.js @@ -14,6 +14,8 @@ class guildCreateListener extends Listener { console.log(`***BOT KICKED***\n${guild.name}\n${guild.memberCount} users\nOwner: ${guild.owner.user.username}\nOwner ID: ${guild.owner}\n***BOT KICKED***`); const channel = this.client.channels.resolve(statsChannel); + let botCount = guild.members.cache.filter(member => member.user.bot).size; + const kickEmbed = this.client.util.embed() .setColor('#FF0000') .setTitle('Some mofo just removed me from there guild :(') @@ -22,8 +24,8 @@ class guildCreateListener extends Listener { .addField('Guild name', guild.name, true) .addField('Guild ID', guild.id, true) .addField('Total number of members', guild.memberCount, true) - .addField('Number of users', guild.members.filter(member => !member.user.bot).size, true) - .addField('Number of bots', guild.members.filter(member => member.user.bot).size, true) + .addField('Number of users', guild.memberCount - botCount, true) + .addField('Number of bots', botCount, true) .addField('Owner', guild.owner.user.username, true) .addField('Owner ID', guild.owner.id, true) .setFooter(`I'm now in ${this.client.guilds.cache.size} servers!`)