mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(GuildMember): add avatarDecorationData (#10942)
* feat(GuildMember): add `avatarDecorationData` * feat: add `displayAvatarDecoration()` * docs: missing `@returns` --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -133,6 +133,20 @@ class GuildMember extends Base {
|
|||||||
} else {
|
} else {
|
||||||
this.flags ??= new GuildMemberFlagsBitField().freeze();
|
this.flags ??= new GuildMemberFlagsBitField().freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.avatar_decoration_data) {
|
||||||
|
/**
|
||||||
|
* The member avatar decoration's data
|
||||||
|
*
|
||||||
|
* @type {?AvatarDecorationData}
|
||||||
|
*/
|
||||||
|
this.avatarDecorationData = {
|
||||||
|
asset: data.avatar_decoration_data.asset,
|
||||||
|
skuId: data.avatar_decoration_data.sku_id,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
this.avatarDecorationData = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_clone() {
|
_clone() {
|
||||||
@@ -181,6 +195,15 @@ class GuildMember extends Base {
|
|||||||
return this.avatar && this.client.rest.cdn.guildMemberAvatar(this.guild.id, this.id, this.avatar, options);
|
return this.avatar && this.client.rest.cdn.guildMemberAvatar(this.guild.id, this.id, this.avatar, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to the member's avatar decoration.
|
||||||
|
*
|
||||||
|
* @returns {?string}
|
||||||
|
*/
|
||||||
|
avatarDecorationURL() {
|
||||||
|
return this.avatarDecorationData ? this.client.rest.cdn.avatarDecoration(this.avatarDecorationData.asset) : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A link to the member's banner.
|
* A link to the member's banner.
|
||||||
*
|
*
|
||||||
@@ -213,6 +236,16 @@ class GuildMember extends Base {
|
|||||||
return this.bannerURL(options) ?? this.user.bannerURL(options);
|
return this.bannerURL(options) ?? this.user.bannerURL(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to the member's guild avatar decoration if they have one.
|
||||||
|
* Otherwise, a link to their {@link User#avatarDecorationURL} will be returned.
|
||||||
|
*
|
||||||
|
* @returns {?string}
|
||||||
|
*/
|
||||||
|
displayAvatarDecorationURL() {
|
||||||
|
return this.avatarDecorationURL() ?? this.user.avatarDecorationURL();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time this member joined the guild
|
* The time this member joined the guild
|
||||||
*
|
*
|
||||||
@@ -560,7 +593,9 @@ class GuildMember extends Base {
|
|||||||
this.flags.bitfield === member.flags.bitfield &&
|
this.flags.bitfield === member.flags.bitfield &&
|
||||||
(this._roles === member._roles ||
|
(this._roles === member._roles ||
|
||||||
(this._roles.length === member._roles.length &&
|
(this._roles.length === member._roles.length &&
|
||||||
this._roles.every((role, index) => role === member._roles[index])))
|
this._roles.every((role, index) => role === member._roles[index]))) &&
|
||||||
|
this.avatarDecorationData?.asset === member.avatarDecorationData?.asset &&
|
||||||
|
this.avatarDecorationData?.skuId === member.avatarDecorationData?.skuId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,6 +622,7 @@ class GuildMember extends Base {
|
|||||||
json.bannerURL = this.bannerURL();
|
json.bannerURL = this.bannerURL();
|
||||||
json.displayAvatarURL = this.displayAvatarURL();
|
json.displayAvatarURL = this.displayAvatarURL();
|
||||||
json.displayBannerURL = this.displayBannerURL();
|
json.displayBannerURL = this.displayBannerURL();
|
||||||
|
json.avatarDecorationURL = this.avatarDecorationURL();
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
packages/discord.js/typings/index.d.ts
vendored
5
packages/discord.js/typings/index.d.ts
vendored
@@ -1596,6 +1596,7 @@ export class GuildMember extends Base {
|
|||||||
private constructor(client: Client<true>, data: unknown, guild: Guild);
|
private constructor(client: Client<true>, data: unknown, guild: Guild);
|
||||||
private readonly _roles: Snowflake[];
|
private readonly _roles: Snowflake[];
|
||||||
public avatar: string | null;
|
public avatar: string | null;
|
||||||
|
public avatarDecorationData: AvatarDecorationData | null;
|
||||||
public banner: string | null;
|
public banner: string | null;
|
||||||
public get bannable(): boolean;
|
public get bannable(): boolean;
|
||||||
public get dmChannel(): DMChannel | null;
|
public get dmChannel(): DMChannel | null;
|
||||||
@@ -1623,6 +1624,7 @@ export class GuildMember extends Base {
|
|||||||
public user: User;
|
public user: User;
|
||||||
public get voice(): VoiceState;
|
public get voice(): VoiceState;
|
||||||
public avatarURL(options?: ImageURLOptions): string | null;
|
public avatarURL(options?: ImageURLOptions): string | null;
|
||||||
|
public avatarDecorationURL(): string | null;
|
||||||
public bannerURL(options?: ImageURLOptions): string | null;
|
public bannerURL(options?: ImageURLOptions): string | null;
|
||||||
public ban(options?: BanOptions): Promise<void>;
|
public ban(options?: BanOptions): Promise<void>;
|
||||||
public disableCommunicationUntil(timeout: DateResolvable | null, reason?: string): Promise<GuildMember>;
|
public disableCommunicationUntil(timeout: DateResolvable | null, reason?: string): Promise<GuildMember>;
|
||||||
@@ -1632,6 +1634,7 @@ export class GuildMember extends Base {
|
|||||||
public deleteDM(): Promise<DMChannel>;
|
public deleteDM(): Promise<DMChannel>;
|
||||||
public displayAvatarURL(options?: ImageURLOptions): string;
|
public displayAvatarURL(options?: ImageURLOptions): string;
|
||||||
public displayBannerURL(options?: ImageURLOptions): string | null;
|
public displayBannerURL(options?: ImageURLOptions): string | null;
|
||||||
|
public displayAvatarDecorationURL(): string | null;
|
||||||
public edit(options: GuildMemberEditOptions): Promise<GuildMember>;
|
public edit(options: GuildMemberEditOptions): Promise<GuildMember>;
|
||||||
public isCommunicationDisabled(): this is GuildMember & {
|
public isCommunicationDisabled(): this is GuildMember & {
|
||||||
readonly communicationDisabledUntil: Date;
|
readonly communicationDisabledUntil: Date;
|
||||||
@@ -3534,7 +3537,7 @@ export class User extends Base {
|
|||||||
public get tag(): string;
|
public get tag(): string;
|
||||||
public username: string;
|
public username: string;
|
||||||
public avatarURL(options?: ImageURLOptions): string | null;
|
public avatarURL(options?: ImageURLOptions): string | null;
|
||||||
public avatarDecorationURL(options?: BaseImageURLOptions): string | null;
|
public avatarDecorationURL(): string | null;
|
||||||
public bannerURL(options?: ImageURLOptions): string | null | undefined;
|
public bannerURL(options?: ImageURLOptions): string | null | undefined;
|
||||||
public createDM(force?: boolean): Promise<DMChannel>;
|
public createDM(force?: boolean): Promise<DMChannel>;
|
||||||
public deleteDM(): Promise<DMChannel>;
|
public deleteDM(): Promise<DMChannel>;
|
||||||
|
|||||||
Reference in New Issue
Block a user