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

Discord
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

Jeffplays2005
<client>.guilds.cache.filter(guild=>guild.members.cache.size < 10).map(guild=>guild.name).join('\n');

The snippet above uses: <client> which is your Discord.Client.

<client>.guilds.cache.filter filters something from the guilds that your bot client is in. The filter, guild=>guild.members.cache.size < 10 is filtering all guilds to guilds with less than 10 members in them. The .map function maps out the filtered map, and the .join('\n') joins the array into a list, split by paragraph breaks.

You can either evaluate the snippet using an eval command or you can place that in a command template.

Hope this helped, if anything fails to work, please comment and I'll try my best to answer!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

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

How to Get a List of Members in a Guild Discord.js

How to get members of a discord guild(discord.py)?

Get guild members and filter them (Discord.js)

How to only get UserID from message.guild.members.fetch() in discord.js v12?

how to get all members of a guild in discord.py?

Getting a list of all guild members and banning them in discord.js using node.js

Is it possible to get the list of all members from a discord guild using non-bot token?

How to get the ID of a guild on join in Discord.js

Discord.JS: How to get first channel of a guild?

How to get owner of a guild in discord.js v13?

Discord JS - How do you get the status of a user within a Guild?

How can i get guild name using discord.py

How to get the user with guild.members.get()?

Discord JS Client only has itself in guild members cache

Discord.js - counter of sent messages, DM to all members of guild

Trying to show all members of guild by bot, Discord JS

How to get guild object using guild ID

Discord.js Get the member in a guild by username

How to autoassign roles to new members joining Discord guild?

How to get username of user not in Discord guild?

Discord.js: How to ban user that is not in the guild?

How would I get all the members from a server using discord.js

Discord Bot - Guild Members Showing in count... but not in guild.members

Change Icon of a Discord Guild using Discord.Js

how to get all members id in discord.js

Discord.js | How to get members currently connected to a Voice Channel?

How do i get the guild ID of a joined user/member (Discord.js)

How to get ID from guild.fetch in discord.js v12?