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 User2y ago
Message Not Public
Sign In & Join Server To View
Araraura
ArarauraOP2y ago
discord.js 14.7.1 and node 19.5.0
Want results from more Discord servers?
Add your server