{"record":{"id":"5874a7c757eeec57","repo":"discordjs/discord.js","slug":"fetchownerid","errorCode":"FetchOwnerId","errorMessage":"FetchOwnerId: guild","messagePattern":"FetchOwnerId: guild","errorType":"error_code","errorClass":"DiscordjsError","httpStatus":null,"severity":"error","filePath":"packages/discord.js/src/structures/Guild.js","lineNumber":577,"sourceCode":"   * The URL to this guild's discovery splash image.\n   *\n   * @param {ImageURLOptions} [options={}] Options for the image URL\n   * @returns {?string}\n   */\n  discoverySplashURL(options = {}) {\n    return this.discoverySplash && this.client.rest.cdn.discoverySplash(this.id, this.discoverySplash, options);\n  }\n\n  /**\n   * Fetches the owner of the guild.\n   * If the member object isn't needed, use {@link Guild#ownerId} instead.\n   *\n   * @param {BaseFetchOptions} [options] The options for fetching the member\n   * @returns {Promise<GuildMember>}\n   */\n  async fetchOwner(options) {\n    if (!this.ownerId) {\n      throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'guild');\n    }\n\n    return this.members.fetch({ ...options, user: this.ownerId });\n  }\n\n  /**\n   * AFK voice channel for this guild\n   *\n   * @type {?VoiceChannel}\n   * @readonly\n   */\n  get afkChannel() {\n    return this.client.channels.resolve(this.afkChannelId);\n  }\n\n  /**\n   * System channel for this guild\n   *","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/discordjs/discord.js/blob/a81ed8a306d37fdc746e26a634b6a42164ba2c8c/packages/discord.js/src/structures/Guild.js#L559-L595","documentation":"FetchOwnerId is thrown by Guild#fetchOwner when the guild's ownerId is falsy — the library doesn't know who the owner is, so it cannot fetch the owner member. This indicates an incomplete or partially available guild object (e.g. an unavailable guild, partial data, or a synthetic guild instance without ownerId populated).","triggerScenarios":"Calling guild.fetchOwner() on a guild whose ownerId is null/undefined — e.g. an unavailable guild during an outage, a guild built from partial data, or data fetched before GUILD_CREATE finished populating ownerId.","commonSituations":"Bot added to a guild but GUILD_CREATE/READY data still streaming in; handling guild objects from events that carry partial payloads; running fetchOwner in an unavailable-guild state after Discord outages; constructing guild objects manually in tests without ownerId.","solutions":["Check guild.available and guild.ownerId before calling fetchOwner: `if (guild.available && guild.ownerId) await guild.fetchOwner()`","Fallback to fetching the member by id from raw event data if available, or await the full guild: `client.guilds.fetch(guild.id)` before fetchOwner","Defer owner lookups until after READY/GUILD_CREATE completes (clientReady/guildCreate events)","If you control construction, always populate ownerId when building Guild objects"],"exampleFix":"// before\nconst owner = await guild.fetchOwner(); // throws if ownerId missing\n// after\nif (!guild.available || !guild.ownerId) return;\nconst owner = await guild.fetchOwner();","handlingStrategy":"validation","validationCode":"if (!guild.available || !guild.ownerId) return;\nconst owner = await guild.fetchOwner();","typeGuard":"function canFetchOwner(guild) {\n  return typeof guild.ownerId === 'string' && /^[0-9]{17,20}$/.test(guild.ownerId);\n}","tryCatchPattern":"try {\n  const owner = await guild.fetchOwner();\n} catch (err) {\n  if (err.name === 'DiscordjsError' && err.message.includes('FetchOwnerId')) {\n    return; // guild data incomplete; retry after READY/GUILD_CREATE\n  }\n  throw err;\n}","preventionTips":["Wait for READY / guildCreate before doing owner lookups","Check guild.available for outage/unavailable guilds","Cache ownerId from raw event payloads as a fallback","Avoid constructing Guild objects manually in scripts without full data"],"tags":["discord-js","guild","unavailable-guild","missing-owner"],"backgroundTag":"guild-owner-unavailable","analyzedSha":"a81ed8a306d37fdc746e26a634b6a42164ba2c8c","analyzedAt":"2026-08-30T04:07:22.193Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}