From c6b78f89afe3b79d56058a60103e507fbd81845e Mon Sep 17 00:00:00 2001 From: Advaith Date: Sun, 4 Apr 2021 20:04:28 -0700 Subject: [PATCH 1/2] feat(Guild): replace `owner` with `fetchOwner` --- src/structures/Guild.js | 23 +++++++++++++---------- typings/index.d.ts | 4 +++- 2 files changed, 16 insertions(+), 11 deletions(-) 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..cf7aef97438a 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(): 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 { From 5913cdb734016452760e0c202e865948ae0a2971 Mon Sep 17 00:00:00 2001 From: Advaith Date: Sun, 4 Apr 2021 20:12:39 -0700 Subject: [PATCH 2/2] types: update --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index cf7aef97438a..8e408d0bd3fa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -659,7 +659,7 @@ declare module 'discord.js' { public fetchBans(): Promise>; public fetchIntegrations(): Promise>; public fetchInvites(): Promise>; - public fetchOwner(): Promise; + public fetchOwner(options?: FetchOwnerOptions): Promise; public fetchPreview(): Promise; public fetchTemplates(): Promise>; public fetchVanityData(): Promise;