Search code examples
node.jsdiscorddiscord.jsnodes

how to get the guild that have less than 10 members using discord.js


const Discord = require('discord.js');
client.guilds.cache.forEach((guild) => {
  if (message.guild.memberCount <= 10) {
    message.channel.send (guild.name)
  }
else return;
  });
    }
}

This code only show the total guild name but i want to get guild that have less than 10 member


Solution

  • That is fairly easy.

        guild.channels.cache.forEach((channel) => {
            if (channel.type === 'text' && !targetChannel && channel.permissionsFor(guild.me).has("SEND_MESSAGES")) targetChannel = channel
        })
    
    
      if(guild.memberCount < 10 ) {
         //code
      }