@@ -151,6 +151,30 @@ class User extends Base {
151151 } else {
152152 this . avatarDecorationData = null ;
153153 }
154+
155+ /**
156+ * @typedef {Object } UserPrimaryGuild
157+ * @property {?Snowflake } identityGuildId - The id of the user's primary guild
158+ * @property {?boolean } identityEnabled - Whether the user is displaying the primary guild's server tag
159+ * @property {?string } tag - The user's server tag. Limited to 4 characters
160+ * @property {?string } badge - The server tag badge hash
161+ */
162+
163+ if ( data . primary_guild ) {
164+ /**
165+ * The primary guild of the user
166+ *
167+ * @type {?UserPrimaryGuild }
168+ */
169+ this . primaryGuild = {
170+ identityGuildId : data . primary_guild . identity_guild_id ,
171+ identityEnabled : data . primary_guild . identity_enabled ,
172+ tag : data . primary_guild . tag ,
173+ badge : data . primary_guild . badge ,
174+ } ;
175+ } else {
176+ this . primaryGuild = null ;
177+ }
154178 }
155179
156180 /**
@@ -246,6 +270,19 @@ class User extends Base {
246270 return this . banner && this . client . rest . cdn . banner ( this . id , this . banner , options ) ;
247271 }
248272
273+ /**
274+ * A link to the user's guild tag badge.
275+ *
276+ * @param {ImageURLOptions } [options={}] Options for the image URL
277+ * @returns {?string }
278+ */
279+ guildTagBadgeURL ( options = { } ) {
280+ return (
281+ this . primaryGuild ?. badge &&
282+ this . client . rest . cdn . guildTagBadge ( this . primaryGuild . identityGuildId , this . primaryGuild . badge , options )
283+ ) ;
284+ }
285+
249286 /**
250287 * The tag of this user
251288 * <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
@@ -338,7 +375,11 @@ class User extends Base {
338375 this . banner === user . banner &&
339376 this . accentColor === user . accentColor &&
340377 this . avatarDecorationData ?. asset === user . avatarDecorationData ?. asset &&
341- this . avatarDecorationData ?. skuId === user . avatarDecorationData ?. skuId
378+ this . avatarDecorationData ?. skuId === user . avatarDecorationData ?. skuId &&
379+ this . primaryGuild ?. identityGuildId === user . primaryGuild ?. identityGuildId &&
380+ this . primaryGuild ?. identityEnabled === user . primaryGuild ?. identityEnabled &&
381+ this . primaryGuild ?. tag === user . primaryGuild ?. tag &&
382+ this . primaryGuild ?. badge === user . primaryGuild ?. badge
342383 ) ;
343384 }
344385
@@ -363,6 +404,12 @@ class User extends Base {
363404 ( 'avatar_decoration_data' in user
364405 ? this . avatarDecorationData ?. asset === user . avatar_decoration_data ?. asset &&
365406 this . avatarDecorationData ?. skuId === user . avatar_decoration_data ?. sku_id
407+ : true ) &&
408+ ( 'primary_guild' in user
409+ ? this . primaryGuild ?. identityGuildId === user . primary_guild ?. identity_guild_id &&
410+ this . primaryGuild ?. identityEnabled === user . primary_guild ?. identity_enabled &&
411+ this . primaryGuild ?. tag === user . primary_guild ?. tag &&
412+ this . primaryGuild ?. badge === user . primary_guild ?. badge
366413 : true )
367414 ) ;
368415 }
@@ -402,6 +449,7 @@ class User extends Base {
402449 json . avatarURL = this . avatarURL ( ) ;
403450 json . displayAvatarURL = this . displayAvatarURL ( ) ;
404451 json . bannerURL = this . banner ? this . bannerURL ( ) : this . banner ;
452+ json . guildTagBadgeURL = this . guildTagBadgeURL ( ) ;
405453 return json ;
406454 }
407455}
0 commit comments