TypeError: Cannot read property 'user' of null

I’ve been trying to run this pretty simple code that lists every single guild my bot is in and the owner of that guild, but I keep getting the same error even though the code seems to be up-to-date.

client.guilds.cache.forEach(guild => {
  msg.channel.send(`${guild.name}` + ` | ` + `${guild.owner.user.tag}`);
});

Edit: It seems that the problem is with guild.owner.user.tag. I still don’t get why it won’t work.

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