Browse Source

Attempt to exclude bots for member count channel

master
Abheek Dhawan 4 years ago
parent
commit
fbc495ece3
  1. 12
      bot.js

12
bot.js

@ -122,7 +122,9 @@ async function memberCountChannelUpdate(member) {
if (result.member_count_channel_id) { if (result.member_count_channel_id) {
memberCountChannel = result.member_count_channel_id; memberCountChannel = result.member_count_channel_id;
if (member.guild.channels.cache.get(memberCountChannel)) { 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!'); message.reply('member count channel already exists!');
} else { } else {
// Create "#bot-logs" text channel to track message deletes, edits, and channel creations // 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', type: 'voice',
// Remove view permissions from "@everyone" // Remove view permissions from "@everyone"
permissionOverwrites: [{ permissionOverwrites: [{
@ -280,7 +284,9 @@ async function memberCountChannelCreate(message) {
} }
} else { } else {
// Create "#bot-logs" text channel to track message deletes, edits, and channel creations // 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', type: 'voice',
// Remove view permissions from "@everyone" // Remove view permissions from "@everyone"
permissionOverwrites: [{ permissionOverwrites: [{

Loading…
Cancel
Save