diff --git a/src/structures/Guild.js b/src/structures/Guild.js index d2690101a677..be780ce8ceee 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -526,17 +526,20 @@ class Guild extends Base { } /** - * The owner of the guild - * @type {?GuildMember} - * @readonly + * Options used to fetch the owner of guild. + * @typedef {Object} FetchOwnerOptions + * @property {boolean} [cache=true] Whether or not to cache the fetched member + * @property {boolean} [force=false] Whether to skip the cache check and request the API */ - get owner() { - return ( - this.members.cache.get(this.ownerID) || - (this.client.options.partials.includes(PartialTypes.GUILD_MEMBER) - ? this.members.add({ user: { id: this.ownerID } }, true) - : null) - ); + + /** + * Fetches the owner of the guild + * If the member object isn't needed, use {@link Guild#ownerID} instead + * @param {FetchOwnerOptions} [options] The options for fetching the member + * @returns {Promise} + */ + fetchOwner(options) { + return this.members.fetch({ ...options, user: this.ownerID }); } /** diff --git a/typings/index.d.ts b/typings/index.d.ts index 1add8b580dc2..8e408d0bd3fa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -619,7 +619,6 @@ declare module 'discord.js' { public mfaLevel: number; public name: string; public readonly nameAcronym: string; - public readonly owner: GuildMember | null; public ownerID: Snowflake; public readonly partnered: boolean; public preferredLocale: string; @@ -660,6 +659,7 @@ declare module 'discord.js' { public fetchBans(): Promise>; public fetchIntegrations(): Promise>; public fetchInvites(): Promise>; + public fetchOwner(options?: FetchOwnerOptions): Promise; public fetchPreview(): Promise; public fetchTemplates(): Promise>; public fetchVanityData(): Promise; @@ -2655,6 +2655,8 @@ declare module 'discord.js' { name?: string; } + type FetchOwnerOptions = Omit; + type GuildAuditLogsAction = keyof GuildAuditLogsActions; interface GuildAuditLogsActions {