@@ -136,20 +136,34 @@ class User extends Base {
|
|||||||
this.flags = new UserFlags(data.public_flags);
|
this.flags = new UserFlags(data.public_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('avatar_decoration_data' in data) {
|
if ('avatar_decoration' in data) {
|
||||||
/**
|
/**
|
||||||
* The user avatar decoration's hash
|
* The user avatar decoration's hash
|
||||||
* @type {?string}
|
* @type {?string}
|
||||||
|
* @deprecated Use `avatarDecorationData` instead
|
||||||
*/
|
*/
|
||||||
this.avatarDecoration = data.avatar_decoration_data?.asset;
|
this.avatarDecoration = data.avatar_decoration;
|
||||||
/**
|
|
||||||
* The ID of the avatar decoration's SKU
|
|
||||||
* @type {?Snowflake}
|
|
||||||
*/
|
|
||||||
this.avatarDecorationSKUId = data.avatar_decoration_data?.sku_id;
|
|
||||||
} else {
|
} else {
|
||||||
this.avatarDecoration ??= null;
|
this.avatarDecoration ??= null;
|
||||||
this.avatarDecorationSKUId ??= null;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} AvatarDecorationData
|
||||||
|
* @property {string} asset The avatar decoration hash
|
||||||
|
* @property {Snowflake} skuId The id of the avatar decoration's SKU
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (data.avatar_decoration_data) {
|
||||||
|
/**
|
||||||
|
* The user 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('clan' in data && data.clan) {
|
if ('clan' in data && data.clan) {
|
||||||
@@ -220,8 +234,10 @@ class User extends Base {
|
|||||||
* @returns {?string}
|
* @returns {?string}
|
||||||
*/
|
*/
|
||||||
avatarDecorationURL({ format, size } = {}) {
|
avatarDecorationURL({ format, size } = {}) {
|
||||||
if (!this.avatarDecoration) return null;
|
if (this.avatarDecorationData) {
|
||||||
return this.client.rest.cdn.AvatarDecoration(this.id, this.avatarDecoration, format, size);
|
return this.client.rest.cdn.AvatarDecoration(this.id, this.avatarDecorationData.asset, format, size);
|
||||||
|
}
|
||||||
|
return this.avatarDecoration && this.client.rest.cdn.AvatarDecoration(this.id, this.avatarDecoration, format, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -344,7 +360,10 @@ class User extends Base {
|
|||||||
this.avatar === user.avatar &&
|
this.avatar === user.avatar &&
|
||||||
this.flags?.bitfield === user.flags?.bitfield &&
|
this.flags?.bitfield === user.flags?.bitfield &&
|
||||||
this.banner === user.banner &&
|
this.banner === user.banner &&
|
||||||
this.accentColor === user.accentColor
|
this.accentColor === user.accentColor &&
|
||||||
|
this.avatarDecoration === user.avatarDecoration &&
|
||||||
|
this.avatarDecorationData?.asset === user.avatarDecorationData?.asset &&
|
||||||
|
this.avatarDecorationData?.skuId === user.avatarDecorationData?.skuId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +383,12 @@ class User extends Base {
|
|||||||
this.avatar === user.avatar &&
|
this.avatar === user.avatar &&
|
||||||
this.flags?.bitfield === user.public_flags &&
|
this.flags?.bitfield === user.public_flags &&
|
||||||
('banner' in user ? this.banner === user.banner : true) &&
|
('banner' in user ? this.banner === user.banner : true) &&
|
||||||
('accent_color' in user ? this.accentColor === user.accent_color : true)
|
('accent_color' in user ? this.accentColor === user.accent_color : true) &&
|
||||||
|
('avatar_decoration' in user ? this.avatarDecoration === user.avatar_decoration : true) &&
|
||||||
|
('avatar_decoration_data' in user
|
||||||
|
? this.avatarDecorationData?.asset === user.avatar_decoration_data?.asset &&
|
||||||
|
this.avatarDecorationData?.skuId === user.avatar_decoration_data?.sku_id
|
||||||
|
: true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
typings/index.d.ts
vendored
8
typings/index.d.ts
vendored
@@ -3370,14 +3370,20 @@ export interface UserClan {
|
|||||||
badge?: string;
|
badge?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AvatarDecorationData {
|
||||||
|
asset: string;
|
||||||
|
skuId: Snowflake;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
public accentColor: number | null | undefined;
|
public accentColor: number | null | undefined;
|
||||||
public avatar: string | null;
|
public avatar: string | null;
|
||||||
|
/** @deprecated Use {@link User.avatarDecorationData} instead */
|
||||||
public avatarDecoration: string | null;
|
public avatarDecoration: string | null;
|
||||||
public avatarDecorationSKUId: Snowflake | null;
|
public avatarDecorationData: AvatarDecorationData | null;
|
||||||
public banner: string | null | undefined;
|
public banner: string | null | undefined;
|
||||||
public bannerColor: string | null | undefined;
|
public bannerColor: string | null | undefined;
|
||||||
public bot: boolean;
|
public bot: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user