fix(guild): throw if ownerId falsey (#7575)

This commit is contained in:
Ryan Munro
2022-03-25 06:58:29 +11:00
committed by GitHub
parent b1d63d919a
commit 98177aa38d
2 changed files with 7 additions and 2 deletions

View File

@@ -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}`,

View File

@@ -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;
}
/**