Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Discord.js Cannot get member by ID on ready function

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!