Finding members with specific emoji in their name problem.

I have this kind of code i made:
callback: async ({ message, args }) => {

const emojiInName = ["🎩"]
let members = await message.guild.members.fetch();
for(let member of members)
if(emojiInName.some(emoji => member.nickname.includes(emoji))){
message.channel.send({ content: `${member} has the emoji in name`})
} else return;

},
callback: async ({ message, args }) => {

const emojiInName = ["🎩"]
let members = await message.guild.members.fetch();
for(let member of members)
if(emojiInName.some(emoji => member.nickname.includes(emoji))){
message.channel.send({ content: `${member} has the emoji in name`})
} else return;

},
But i get this: TypeError: Cannot read properties of undefined (reading 'includes')
10 Replies
Squid
Squid•3y ago
It would be null, not undefined You should iterate over members.values() instead of members, or else each member is a [string, GuildMember] array instead of just a GuildMember object (but using displayName is still probably the way to go if you're not doing optional chaining)
Frosty
Frosty•3y ago
callback: async ({ message, args }) => {

const emojiInName = ["🎩"]
let members = await message.guild.members.fetch();
for(let member of members) {
if(emojiInName.some(emoji => members.values().displayName.includes(emoji))){
message.channel.send({ content: `${member} has the emoji in name`})
}
}

},
callback: async ({ message, args }) => {

const emojiInName = ["🎩"]
let members = await message.guild.members.fetch();
for(let member of members) {
if(emojiInName.some(emoji => members.values().displayName.includes(emoji))){
message.channel.send({ content: `${member} has the emoji in name`})
}
}

},
So something like thsi?
Jaworek
Jaworek•3y ago
members.values() is iterable and for sure it doesn't have displayName poperty
Frosty
Frosty•3y ago
But if i do it like this?
let members = await message.guild.members.fetch();

for (let member of members) {

if (member.displayName.includes("🎩")) {
console.log("someone has the thing");
}

}
let members = await message.guild.members.fetch();

for (let member of members) {

if (member.displayName.includes("🎩")) {
console.log("someone has the thing");
}

}
Jaworek
Jaworek•3y ago
in this case member is array of key and value
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Frosty
Frosty•3y ago
I got it working.
Jaworek
Jaworek•3y ago
meguFace
Frosty
Frosty•3y ago
let membersHat = await message.guild.members.cache.filter(
(member) =>
member.nickname && member.nickname.toLowerCase().includes("🎩")
);
if (membersHat.size === 0) console.log("No members found");

let countHat = 0;
membersHat.forEach((member) => {
countHat = countHat + 1;
});
let membersHat = await message.guild.members.cache.filter(
(member) =>
member.nickname && member.nickname.toLowerCase().includes("🎩")
);
if (membersHat.size === 0) console.log("No members found");

let countHat = 0;
membersHat.forEach((member) => {
countHat = countHat + 1;
});
used something like this. Ignore the count thing.
Jaworek
Jaworek•3y ago
its filter, you can use forEach instead
Want results from more Discord servers?
Add your server
More Posts
Should I wait until Discord.JS 14 to start working on my bot?I was thinking of getting back to Discord bot development and I don't know if I should start workingOauth2 bot replyIm stuck if somebody can help: I got the info from the Oauth2, but now im lost as to how to send bacDoes it run? Like does the v14 work so a bot can use it?Hello i wonder if i can update my bot to v14 so it works and runs normal? Just so i can try or shoulApplication Command Permissions - Bearer Token requiredI wanted to change permission overwrites for my commands, but, as you can see in the screenshot beloEmbed not populating?My command: https://srcb.in/ckid4AXlBk The `console.log(embeds)`: https://srcb.in/0zq3X8Ramm It logBeen a while since I coded with DJS. How do I listen for the (not as new but still newer) replies...I am not sure how to listen to replies like the attached image. This works to run commands and I'd lWeird DJS err... something about cannot use 'in' operator to search for color?This is my command: https://srcb.in/832iYRGVCa I saw that we can now use embed objects here: https:Been a bit since I worked with DJS V13, How do I add multiple buttons again?I have this code: ```javascript const row = new MessageActionRow() .addComponentTypeError Cannot read properties of undefined (reading 'permissions')Hello, i have this piece of code and i get this error. Code: ```js if (message.member.roles.cacheproblem with timeouthey, when I want to check if a user is timeouted, when my bot restarts, my friend is timeouted but t