mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
feat(Guild): replace owner with fetchOwner (#5480)
This commit is contained in:
@@ -528,17 +528,20 @@ class Guild extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The owner of the guild
|
* Options used to fetch the owner of guild.
|
||||||
* @type {?GuildMember}
|
* @typedef {Object} FetchOwnerOptions
|
||||||
* @readonly
|
* @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) ||
|
* Fetches the owner of the guild
|
||||||
(this.client.options.partials.includes(PartialTypes.GUILD_MEMBER)
|
* If the member object isn't needed, use {@link Guild#ownerID} instead
|
||||||
? this.members.add({ user: { id: this.ownerID } }, true)
|
* @param {FetchOwnerOptions} [options] The options for fetching the member
|
||||||
: null)
|
* @returns {Promise<GuildMember>}
|
||||||
);
|
*/
|
||||||
|
fetchOwner(options) {
|
||||||
|
return this.members.fetch({ ...options, user: this.ownerID });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@@ -641,7 +641,6 @@ declare module 'discord.js' {
|
|||||||
public mfaLevel: number;
|
public mfaLevel: number;
|
||||||
public name: string;
|
public name: string;
|
||||||
public readonly nameAcronym: string;
|
public readonly nameAcronym: string;
|
||||||
public readonly owner: GuildMember | null;
|
|
||||||
public ownerID: Snowflake;
|
public ownerID: Snowflake;
|
||||||
public readonly partnered: boolean;
|
public readonly partnered: boolean;
|
||||||
public preferredLocale: string;
|
public preferredLocale: string;
|
||||||
@@ -682,6 +681,7 @@ declare module 'discord.js' {
|
|||||||
public fetchBans(): Promise<Collection<Snowflake, { user: User; reason: string }>>;
|
public fetchBans(): Promise<Collection<Snowflake, { user: User; reason: string }>>;
|
||||||
public fetchIntegrations(): Promise<Collection<string, Integration>>;
|
public fetchIntegrations(): Promise<Collection<string, Integration>>;
|
||||||
public fetchInvites(): Promise<Collection<string, Invite>>;
|
public fetchInvites(): Promise<Collection<string, Invite>>;
|
||||||
|
public fetchOwner(options?: FetchOwnerOptions): Promise<GuildMember>;
|
||||||
public fetchPreview(): Promise<GuildPreview>;
|
public fetchPreview(): Promise<GuildPreview>;
|
||||||
public fetchTemplates(): Promise<Collection<GuildTemplate['code'], GuildTemplate>>;
|
public fetchTemplates(): Promise<Collection<GuildTemplate['code'], GuildTemplate>>;
|
||||||
public fetchVanityData(): Promise<Vanity>;
|
public fetchVanityData(): Promise<Vanity>;
|
||||||
@@ -2697,6 +2697,8 @@ declare module 'discord.js' {
|
|||||||
name?: string;
|
name?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FetchOwnerOptions = Omit<FetchMemberOptions, 'user'>;
|
||||||
|
|
||||||
type GuildAuditLogsAction = keyof GuildAuditLogsActions;
|
type GuildAuditLogsAction = keyof GuildAuditLogsActions;
|
||||||
|
|
||||||
interface GuildAuditLogsActions {
|
interface GuildAuditLogsActions {
|
||||||
|
|||||||
Reference in New Issue
Block a user