Search code examples
node.jsdiscorddiscord.jsnodes

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


I want to send guild name list in channel that have less than 10 member. {USING discord.js v13}

My code


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


  if(guild.memberCount < 10 ) {
     message.channel.send (guild.name);
  }

Solution

  • You can just do

    client.guilds.cache.forEach(g => {
       if(g.memberCount < 10) {
          message.channel.send(g.name) 
       }
    })