mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(guild): throw if ownerId falsey (#7575)
This commit is contained in:
@@ -90,6 +90,7 @@ const Messages = {
|
|||||||
CHANNEL_NOT_CACHED: 'Could not find the channel where this message came from in the cache!',
|
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.',
|
STAGE_CHANNEL_RESOLVE: 'Could not resolve channel to a stage channel.',
|
||||||
GUILD_SCHEDULED_EVENT_RESOLVE: 'Could not resolve the guild scheduled event.',
|
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_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}`,
|
INVALID_ELEMENT: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
|
||||||
|
|||||||
@@ -451,8 +451,12 @@ class Guild extends AnonymousGuild {
|
|||||||
* @param {BaseFetchOptions} [options] The options for fetching the member
|
* @param {BaseFetchOptions} [options] The options for fetching the member
|
||||||
* @returns {Promise<GuildMember>}
|
* @returns {Promise<GuildMember>}
|
||||||
*/
|
*/
|
||||||
fetchOwner(options) {
|
async fetchOwner(options) {
|
||||||
return this.members.fetch({ ...options, user: this.ownerId });
|
if (!this.ownerId) {
|
||||||
|
throw new Error('FETCH_OWNER_ID');
|
||||||
|
}
|
||||||
|
const member = await this.members.fetch({ ...options, user: this.ownerId });
|
||||||
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user