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
<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.
Comments