From fbc495ece379e350a33bdda73cf9c596c7604711 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Mon, 5 Apr 2021 14:35:20 -0500 Subject: [PATCH] Attempt to exclude bots for member count channel --- bot.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index 56b2799..3d1f7a8 100644 --- a/bot.js +++ b/bot.js @@ -122,7 +122,9 @@ async function memberCountChannelUpdate(member) { if (result.member_count_channel_id) { memberCountChannel = result.member_count_channel_id; if (member.guild.channels.cache.get(memberCountChannel)) { - member.guild.channels.cache.get(memberCountChannel).edit({ name: `Members: ${member.guild.memberCount}` }).catch(console.error); + await member.guild.members.fetch(); + const numHumans = member.guild.members.cache.filter(member => !member.user.bot).size; + member.guild.channels.cache.get(memberCountChannel).edit({ name: `Members: ${numHumans}` }).catch(console.error); } } }); @@ -264,7 +266,9 @@ async function memberCountChannelCreate(message) { message.reply('member count channel already exists!'); } else { // Create "#bot-logs" text channel to track message deletes, edits, and channel creations - message.guild.channels.create(`Members: ${message.guild.memberCount}`, { + await message.guild.members.fetch(); + const numHumans = message.guild.members.cache.filter(member => !member.user.bot).size; + message.guild.channels.create(`Members: ${numHumans}`, { type: 'voice', // Remove view permissions from "@everyone" permissionOverwrites: [{ @@ -280,7 +284,9 @@ async function memberCountChannelCreate(message) { } } else { // Create "#bot-logs" text channel to track message deletes, edits, and channel creations - message.guild.channels.create(`Members: ${message.guild.memberCount}`, { + await message.guild.members.fetch(); + const numHumans = message.guild.members.cache.filter(member => !member.user.bot).size; + message.guild.channels.create(`Members: ${numHumans}`, { type: 'voice', // Remove view permissions from "@everyone" permissionOverwrites: [{