Skip to content

Commit

Permalink
fix(guild): throw if ownerId falsey (#7575)
Browse files Browse the repository at this point in the history
  • Loading branch information
monbrey committed Mar 24, 2022
1 parent b1d63d9 commit 98177aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/discord.js/src/errors/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
8 changes: 6 additions & 2 deletions packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,12 @@ class Guild extends AnonymousGuild {
* @param {BaseFetchOptions} [options] The options for fetching the member
* @returns {Promise<GuildMember>}
*/
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;
}

/**
Expand Down

0 comments on commit 98177aa

Please sign in to comment.