Please describe the problem you are having in as much detail as possible:
Can not get all user IDs on a server.
Include a reproducible code sample here, if possible:
let channels = client.guilds.cache;
console.log('channels', channels);
for (let [key, value] of channels) {
console.log('value.memberCount', value.memberCount) // return 3
console.log('value.members.cache.size', value.members.cache.size) // reutrn 1
value.members.cache.forEach(data => {
console.log('value.members.cache.forEach', data)
}) // return bot info
value.members.fetch()
.then(console.log)
.catch(console.error); // no data
}
Where are the others? 3 people in total.
but use
let channels = client.guilds.cache;
console.log('channels', channels);
for (let [key, value] of channels) {
value.members
.fetch({ user: '123456' })
.then(console.log)
.catch(console.error);
}
I can get the user
I want to get all user IDs on a server.
Further details:
Relevant client options:
I have the same problem. The only user in cache is the client user.
When I use await guild.members.fetch() the promise never resolve or reject, it just hang.
not a bug: #4961
不是错误:#4961
const client = new Discord.Client(
{fetchAllMembers: true}
);
How to solve this problem, this code does not work
Events for privileged intents are not sent if not enabled:
Yes, I have solved this problem, thank you very much, need to add code and set this

const client = new Discord.Client(
{fetchAllMembers: true}
);
fetchAllMembers options will use loooooog time
thank you very much @millette @advaith1
@netcell you can use the setting and the code
Most helpful comment
Yes, I have solved this problem, thank you very much, need to add code and set this
const client = new Discord.Client(
{fetchAllMembers: true}
);
fetchAllMembers options will use loooooog time
thank you very much @millette @advaith1
@netcell you can use the setting and the code