#How can I loop through all discord members in a Discord?
1 messages · Page 1 of 1 (latest)
Yes
for(let member of await guild.members.fetch())
member.user.id
D:\Git-Discord\Cloud-Bot\index.js:41
console.log(member.user.id)
^
TypeError: Cannot read properties of undefined (reading 'id')
at Client.<anonymous> (D:\Git-Discord\Cloud-Bot\index.js:41:33)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
for(let member of await bot.guilds.cache.get('878392936574894081').members.fetch()){
console.log(member.user.id)
}
Oh...
member.id, sorry
What I wrote above works too, but it fails for some special cases
undefined
Could you show me member object?
yes
sec
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
or do i need to stringify this?
After fetch promise finishes, use .values()
for(let member of (await guild.members.fetch()).values())
console.log(member.id);
Works now, but says "Object [Array Iterator] {}" at the start