Can't fetch owner on guild join

I'm trying to fetch the guild owner and send them a message when my bot joins, but my bot is giving me errors: The syntax is discordx, but the problem is still in the regular discord.js lines:
@On({ event: "guildCreate" })
async newServer(guild: Guild) {
const guildOwner = await guild.members.fetch(guild.ownerId); // TypeError: Cannot read properties of undefined (reading 'fetch')
await guildOwner.send(welcomeMessage(guild.name));
@On({ event: "guildCreate" })
async newServer(guild: Guild) {
const guildOwner = await guild.members.fetch(guild.ownerId); // TypeError: Cannot read properties of undefined (reading 'fetch')
await guildOwner.send(welcomeMessage(guild.name));
I also tried using guild.fetchOwner but that gave me guild.fetchOwner is not a function
2 Replies
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
Araraura
Araraura17mo ago
discord.js 14.7.1 and node 19.5.0