I have not used the latest Discord.js version 13 so I am quite unfamiliar with it.
I am trying to get a member by its ID on the client ready function.
client.guilds.cache.get("x").members.cache.get("x")
Members returns as undefined. This however works with members.fetch(), but I am not able to use this in my code.
But for some reason, this code works
client.guilds.cache.forEach((guild) => {
guild.members.cache.forEach((member) => {
console.log(member)
});
});
Please help as I have tried this in the previous Discord.js v12 and it works perfectly fine.
client.guilds.cache.get("x").members.cache.get("x")
might not work due to either the guild or the member being uncached hence, unavialable to your client through cache you attemmpted to use member.fetch() as you said in your question although were unable to do so, maybe trying a wrong approach? let's try it right here!
client.once("ready", () => {
const guildId = 123456789012345678 // guild you want to fetch
const memberId = 123456789012345678 // member you want to fetch
client.guilds.fetch(`${guildId}`).then( (g) => { g.members.fetch(`${memberId}`) });
});
Easy stuff! feel free to comment if you face any other errors!