#Can't fetch owner on guild join

2 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

wheat kindle
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.