#Can't fetch owner on guild join

1 messages · Page 1 of 1 (latest)

bold bluff

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));

I also tried using guild.fetchOwner but that gave me guild.fetchOwner is not a function