discordjs/discord.js · error · DiscordjsError
FetchOwnerId
FetchOwnerId
Error message
FetchOwnerId: guild
What it means
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).
Source
Thrown at packages/discord.js/src/structures/Guild.js:577
* The URL to this guild's discovery splash image.
*
* @param {ImageURLOptions} [options={}] Options for the image URL
* @returns {?string}
*/
discoverySplashURL(options = {}) {
return this.discoverySplash && this.client.rest.cdn.discoverySplash(this.id, this.discoverySplash, options);
}
/**
* Fetches the owner of the guild.
* If the member object isn't needed, use {@link Guild#ownerId} instead.
*
* @param {BaseFetchOptions} [options] The options for fetching the member
* @returns {Promise<GuildMember>}
*/
async fetchOwner(options) {
if (!this.ownerId) {
throw new DiscordjsError(ErrorCodes.FetchOwnerId, 'guild');
}
return this.members.fetch({ ...options, user: this.ownerId });
}
/**
* AFK voice channel for this guild
*
* @type {?VoiceChannel}
* @readonly
*/
get afkChannel() {
return this.client.channels.resolve(this.afkChannelId);
}
/**
* System channel for this guild
*View on GitHub (pinned to a81ed8a306)
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
Example fix
// before const owner = await guild.fetchOwner(); // throws if ownerId missing // after if (!guild.available || !guild.ownerId) return; const owner = await guild.fetchOwner();
Defensive patterns
Strategy: validation
Validate before calling
if (!guild.available || !guild.ownerId) return; const owner = await guild.fetchOwner();
Type guard
function canFetchOwner(guild) {
return typeof guild.ownerId === 'string' && /^[0-9]{17,20}$/.test(guild.ownerId);
} Try / catch
try {
const owner = await guild.fetchOwner();
} catch (err) {
if (err.name === 'DiscordjsError' && err.message.includes('FetchOwnerId')) {
return; // guild data incomplete; retry after READY/GUILD_CREATE
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of discordjs/discord.js@a81ed8a306 (2026-08-30).
Data as JSON: /api/errors/5874a7c757eeec57.
Report an issue: GitHub.