Skip to content

Commit b0e6aff

Browse files
almeidxJiralite
authored andcommitted
feat(GuildMember): add collectibles (#11468)
feat(GuildMember): add collectibles, fix partial update handling
1 parent 16fd248 commit b0e6aff

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

packages/discord.js/src/structures/GuildMember.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { DiscordjsError, ErrorCodes } = require('../errors');
88
const GuildMemberRoleManager = require('../managers/GuildMemberRoleManager');
99
const { GuildMemberFlagsBitField } = require('../util/GuildMemberFlagsBitField');
1010
const PermissionsBitField = require('../util/PermissionsBitField');
11+
const { _transformCollectibles } = require('../util/Transformers.js');
1112

1213
/**
1314
* Represents a member of a guild on Discord.
@@ -140,6 +141,17 @@ class GuildMember extends Base {
140141
} else {
141142
this.avatarDecorationData = null;
142143
}
144+
145+
if ('collectibles' in data) {
146+
/**
147+
* The member's collectibles
148+
*
149+
* @type {?Collectibles}
150+
*/
151+
this.collectibles = data.collectibles ? _transformCollectibles(data.collectibles) : null;
152+
} else {
153+
this.collectibles ??= null;
154+
}
143155
}
144156

145157
_clone() {
@@ -541,7 +553,11 @@ class GuildMember extends Base {
541553
(this._roles.length === member._roles.length &&
542554
this._roles.every((role, index) => role === member._roles[index]))) &&
543555
this.avatarDecorationData?.asset === member.avatarDecorationData?.asset &&
544-
this.avatarDecorationData?.skuId === member.avatarDecorationData?.skuId
556+
this.avatarDecorationData?.skuId === member.avatarDecorationData?.skuId &&
557+
this.collectibles?.nameplate?.skuId === member.collectibles?.nameplate?.skuId &&
558+
this.collectibles?.nameplate?.asset === member.collectibles?.nameplate?.asset &&
559+
this.collectibles?.nameplate?.label === member.collectibles?.nameplate?.label &&
560+
this.collectibles?.nameplate?.palette === member.collectibles?.nameplate?.palette
545561
);
546562
}
547563

packages/discord.js/src/structures/User.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ class User extends Base {
172172
* @property {?NameplateData} nameplate The user's nameplate data
173173
*/
174174

175-
if (data.collectibles) {
175+
if ('collectibles' in data) {
176176
/**
177177
* The user's collectibles
178178
*
179179
* @type {?Collectibles}
180180
*/
181-
this.collectibles = _transformCollectibles(data.collectibles);
181+
this.collectibles = data.collectibles ? _transformCollectibles(data.collectibles) : null;
182182
} else {
183-
this.collectibles = null;
183+
this.collectibles ??= null;
184184
}
185185

186186
/**

packages/discord.js/typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,7 @@ export class GuildMember extends Base {
18791879
public avatarDecorationData: AvatarDecorationData | null;
18801880
public banner: string | null;
18811881
public get bannable(): boolean;
1882+
public collectibles: Collectibles | null;
18821883
public get dmChannel(): DMChannel | null;
18831884
public get displayColor(): number;
18841885
public get displayHexColor(): HexColorString;

0 commit comments

Comments
 (0)