Reputation: 55
I have a function that takes random users from the server, but I wanted to remove the bots, so that the function takes only true users
getMember: function (message, toFind = '') {
toFind = toFind.toLowerCase();
let target = message.guild.members.cache.get(toFind);
if (!target && message.mentions.members)
target = message.mentions.members.first();
if (!target && toFind) {
target = message.guild.members.cache.find(member => {
return member.displayName.toLowerCase().includes(toFind) ||
member.user.tag.toLowerCase().includes(toFind)
});
}
if (!target)
target = message.member;
return target;
}
Upvotes: 1
Views: 70
Reputation: 220
member.user.bot
returns a boolean value representing if the member is a bot or not
you can filter the members collection to not contain bots by doing
let membersNoBots = message.guild.members.cache.filter(m => !m.user.bot);
Upvotes: 1