diff --git a/packages/discord.js/src/errors/Messages.js b/packages/discord.js/src/errors/Messages.js index 0660d3ccc..0d50cbed0 100644 --- a/packages/discord.js/src/errors/Messages.js +++ b/packages/discord.js/src/errors/Messages.js @@ -90,6 +90,7 @@ const Messages = { CHANNEL_NOT_CACHED: 'Could not find the channel where this message came from in the cache!', STAGE_CHANNEL_RESOLVE: 'Could not resolve channel to a stage channel.', GUILD_SCHEDULED_EVENT_RESOLVE: 'Could not resolve the guild scheduled event.', + FETCH_OWNER_ID: "Couldn't resolve the guild ownerId to fetch the member.", INVALID_TYPE: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`, INVALID_ELEMENT: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`, diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 4474d4d71..42d7d0391 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -451,8 +451,12 @@ class Guild extends AnonymousGuild { * @param {BaseFetchOptions} [options] The options for fetching the member * @returns {Promise} */ - fetchOwner(options) { - return this.members.fetch({ ...options, user: this.ownerId }); + async fetchOwner(options) { + if (!this.ownerId) { + throw new Error('FETCH_OWNER_ID'); + } + const member = await this.members.fetch({ ...options, user: this.ownerId }); + return member; } /**