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

321
Views
TypeError: Cannot read property 'members' of undefined in discord.js \\\
const guild = client.guilds.cache.get("771238821550620703");
   setInterval(function () {
      var memberCount = guild.members.filter(member => !member.user.bot).size;  
      var memberCountChannel = client.channels.get("886555053421375501");
      memberCountChannel.setName(`╭・🍸:Online :${memberCount}`);
   }, 10000);

TypeError: Cannot read property 'members' of undefined

I have checked the channel id and server id hundred times but it is still not working..

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

0

  1. client.channels.get(...) is not a function. The correct method would be client.channels.cache.get(...).
  2. You should always fetch the guild instead of searching the cache, especially as more guilds get added.

Example:

(async () => {
    const guild = await client.guilds.fetch("771238821550620703");
    setInterval(function () {
        var memberCount = guild.members.filter(member => !member.user.bot).size;
        var memberCountChannel = guild.channels.get("886555053421375501");
        memberCountChannel.setName(`╭・🍸:Online :${memberCount}`);
    }, 10000);
});
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!