feat(User): add collectibles

#10939
This commit is contained in:
Elysia
2025-09-13 17:44:51 +07:00
parent 31f917c242
commit 0d45d3ddb9
4 changed files with 130 additions and 1 deletions

View File

@@ -178,6 +178,38 @@ class User extends Base {
} else { } else {
this.primaryGuild ??= null; this.primaryGuild ??= null;
} }
/**
* @typedef {Object} NameplateData
* @property {Snowflake} skuId The id of the nameplate's SKU
* @property {string} asset The nameplate's asset path
* @property {string} label The nameplate's label
* @property {NameplatePalette} palette Background color of the nameplate
*/
/**
* @typedef {Object} Collectibles
* @property {?NameplateData} nameplate The user's nameplate data
*/
if (data.collectibles) {
/**
* The user's collectibles
* @type {?Collectibles}
*/
this.collectibles = data.collectibles.nameplate
? {
nameplate: {
skuId: data.collectibles.nameplate.sku_id,
asset: data.collectibles.nameplate.asset,
label: data.collectibles.nameplate.label,
palette: data.collectibles.nameplate.palette,
},
}
: { nameplate: null };
} else {
this.collectibles = null;
}
} }
/** /**
@@ -367,7 +399,11 @@ class User extends Base {
this.banner === user.banner && this.banner === user.banner &&
this.accentColor === user.accentColor && this.accentColor === user.accentColor &&
this.avatarDecorationData?.asset === user.avatarDecorationData?.asset && this.avatarDecorationData?.asset === user.avatarDecorationData?.asset &&
this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId &&
this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.skuId &&
this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
); );
} }
@@ -391,6 +427,12 @@ class User extends Base {
('avatar_decoration_data' in user ('avatar_decoration_data' in user
? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset && ? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset &&
this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id
: true) &&
('collectibles' in user
? this.collectibles?.nameplate?.skuId === user.collectibles?.nameplate?.sku_id &&
this.collectibles?.nameplate?.asset === user.collectibles?.nameplate?.asset &&
this.collectibles?.nameplate?.label === user.collectibles?.nameplate?.label &&
this.collectibles?.nameplate?.palette === user.collectibles?.nameplate?.palette
: true) : true)
); );
} }

View File

@@ -28,6 +28,11 @@
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/MessageActivityType} * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/MessageActivityType}
*/ */
/**
* @external NameplatePalette
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/NameplatePalette}
*/
/** /**
* @external PollLayoutType * @external PollLayoutType
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/PollLayoutType} * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/PollLayoutType}

69
typings/enums.d.ts vendored
View File

@@ -266,6 +266,75 @@ export const enum NSFWLevels {
AGE_RESTRICTED = 3, AGE_RESTRICTED = 3,
} }
/**
* Background color of a nameplate.
* @see {@link https://docs.discord.food/resources/user#nameplate-color-palette}
*/
export enum NameplatePalette {
/**
* Value: none
* Name: None
*/
None = 'none',
/**
* Value: crimson
* Name: Crimson
*/
Crimson = 'crimson',
/**
* Value: berry
* Name: Berry
*/
Berry = 'berry',
/**
* Value: sky
* Name: Sky
*/
Sky = 'sky',
/**
* Value: teal
* Name: Teal
*/
Teal = 'teal',
/**
* Value: forest
* Name: Forest
*/
Forest = 'forest',
/**
* Value: bubble_gum
* Name: BubbleGum
*/
BubbleGum = 'bubble_gum',
/**
* Value: violet
* Name: Violet
*/
Violet = 'violet',
/**
* Value: cobalt
* Name: Cobalt
*/
Cobalt = 'cobalt',
/**
* Value: clover
* Name: Clover
*/
Clover = 'clover',
/**
* Value: lemon
* Name: Lemon
*/
Lemon = 'lemon',
/**
* Value: white
* Name: White
*/
White = 'white',
}
export const enum OverwriteTypes { export const enum OverwriteTypes {
role = 0, role = 0,
member = 1, member = 1,

13
typings/index.d.ts vendored
View File

@@ -121,6 +121,7 @@ import {
MessageReferenceTypes, MessageReferenceTypes,
SeparatorSpacingSizes, SeparatorSpacingSizes,
ApplicationType, ApplicationType,
NameplatePalette,
} from './enums'; } from './enums';
import { import {
APIApplicationRoleConnectionMetadata, APIApplicationRoleConnectionMetadata,
@@ -3727,6 +3728,17 @@ export interface AvatarDecorationData {
skuId: Snowflake; skuId: Snowflake;
} }
export interface NameplateData {
asset: string;
label: string;
palette: NameplatePalette;
skuId: Snowflake;
}
export interface Collectibles {
nameplate: NameplateData | null;
}
export class User extends PartialTextBasedChannel(Base) { export class User extends PartialTextBasedChannel(Base) {
protected constructor(client: Client, data: RawUserData); protected constructor(client: Client, data: RawUserData);
private _equals(user: APIUser): boolean; private _equals(user: APIUser): boolean;
@@ -3741,6 +3753,7 @@ export class User extends PartialTextBasedChannel(Base) {
public bot: boolean; public bot: boolean;
public readonly createdAt: Date; public readonly createdAt: Date;
public readonly createdTimestamp: number; public readonly createdTimestamp: number;
public collectibles: Collectibles | null;
public discriminator: string; public discriminator: string;
public readonly displayName: string; public readonly displayName: string;
public readonly defaultAvatarURL: string; public readonly defaultAvatarURL: string;