feat(Guild): replace owner with fetchOwner (#5480)

This commit is contained in:
Advaith
2021-04-15 21:39:12 -07:00
committed by GitHub
parent 3c175cb511
commit 1be67b8851
2 changed files with 16 additions and 11 deletions

View File

@@ -528,17 +528,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<GuildMember>}
*/
fetchOwner(options) {
return this.members.fetch({ ...options, user: this.ownerID });
}
/**

4
typings/index.d.ts vendored
View File

@@ -641,7 +641,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;
@@ -682,6 +681,7 @@ declare module 'discord.js' {
public fetchBans(): Promise<Collection<Snowflake, { user: User; reason: string }>>;
public fetchIntegrations(): Promise<Collection<string, Integration>>;
public fetchInvites(): Promise<Collection<string, Invite>>;
public fetchOwner(options?: FetchOwnerOptions): Promise<GuildMember>;
public fetchPreview(): Promise<GuildPreview>;
public fetchTemplates(): Promise<Collection<GuildTemplate['code'], GuildTemplate>>;
public fetchVanityData(): Promise<Vanity>;
@@ -2697,6 +2697,8 @@ declare module 'discord.js' {
name?: string;
}
type FetchOwnerOptions = Omit<FetchMemberOptions, 'user'>;
type GuildAuditLogsAction = keyof GuildAuditLogsActions;
interface GuildAuditLogsActions {