TypeError: Cannot read property 'members' of undefined acil cevap lazım

const owners = guild.members.cache.filter(x => x.roles.cache.has(conf.ownerRole));

Hatayı burada alıyorum nolur sadece Türkler cevap versin

The error is essentially saying that guild is nothing, so before you try to access things in guild, remember to test whether it exists:

if (!guild) {
  // this is probably a problem, requiring some kind of error code path
} else {
  const owners = guild.members.....
}

Alternatively, modern JS also lets you do the following:

const owners = guild?.members.cache......

using the “optional chaining” syntax (Optional chaining (?.) - JavaScript | MDN), but the downside of that syntax is that there’s no error, which you probably want if guild doesn’t exist =)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.