diff --git a/src/structures/User.js b/src/structures/User.js index b6a463d..1406134 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -175,6 +175,16 @@ class User extends Base { */ this.botInGuildsCount = data.approximate_guild_count; } + + if ('avatar_decoration' in data) { + /** + * The user avatar decoration's hash + * @type {?string} + */ + this.avatarDecoration = data.avatar_decoration; + } else { + this.avatarDecoration ??= null; + } } /** @@ -401,6 +411,16 @@ class User extends Base { return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size, dynamic); } + /** + * A link to the user's avatar decoration. + * @param {StaticImageURLOptions} [options={}] Options for the image URL + * @returns {?string} + */ + avatarDecorationURL({ format, size } = {}) { + if (!this.avatarDecoration) return null; + return this.client.rest.cdn.AvatarDecoration(this.id, this.avatarDecoration, format, size); + } + /** * A link to the user's default avatar * @type {string} diff --git a/src/util/Constants.js b/src/util/Constants.js index 7cc91c1..30cde4d 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -196,6 +196,8 @@ exports.Endpoints = { if (dynamic && hash.startsWith('a_')) format = 'gif'; return makeImageUrl(`${root}/avatars/${userId}/${hash}`, { format, size }); }, + AvatarDecoration: (userId, hash, format = 'png', size) => + makeImageUrl(`${root}/avatar-decorations/${userId}/${hash}`, { format, size }), GuildMemberAvatar: (guildId, memberId, hash, format = 'webp', size, dynamic = false) => { if (dynamic && hash.startsWith('a_')) format = 'gif'; return makeImageUrl(`${root}/guilds/${guildId}/users/${memberId}/avatars/${hash}`, { format, size }); diff --git a/typings/index.d.ts b/typings/index.d.ts index 8fe011c..4eefe15 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3069,6 +3069,7 @@ export class User extends PartialTextBasedChannel(Base) { public application: ClientApplication; public accentColor: number | null | undefined; public avatar: string | null; + public avatarDecoration: string | null; public banner: string | null | undefined; public bot: boolean; public readonly createdAt: Date; @@ -3095,6 +3096,7 @@ export class User extends PartialTextBasedChannel(Base) { public readonly mutualFriends: Promise>; public readonly voice: VoiceState; public avatarURL(options?: ImageURLOptions): string | null; + public avatarDecorationURL(options?: StaticImageURLOptions): string | null; public bannerURL(options?: ImageURLOptions): string | null; public createDM(force?: boolean): Promise; public deleteDM(): Promise;