diff --git a/lib/structures/Role.ts b/lib/structures/Role.ts index 5987f61a..8558ef1c 100644 --- a/lib/structures/Role.ts +++ b/lib/structures/Role.ts @@ -3,7 +3,7 @@ import Base from "./Base"; import Permission from "./Permission"; import type Guild from "./Guild"; import type Client from "../Client"; -import type { RawRole, RoleTags, EditRoleOptions } from "../types/guilds"; +import type { RawRole, RoleTags, EditRoleOptions, RoleColors } from "../types/guilds"; import type { JSONRole } from "../types/json"; import { UncachedError } from "../util/Errors"; @@ -12,6 +12,8 @@ export default class Role extends Base { private _cachedGuild?: Guild; /** The color of this role. */ color: number; + /** The colors of this role. */ + colors: RoleColors; /** The {@link Constants~RoleFlags | flags } for this role. */ flags: number; /** The id of the guild this role is in. */ @@ -37,6 +39,11 @@ export default class Role extends Base { constructor(data: RawRole, client: Client, guildID: string) { super(data.id, client); this.color = data.color; + this.colors = { + primaryColor: data.colors.primary_color, + secondaryColor: data.colors.secondary_color, + tertiaryColor: data.colors.tertiary_color + }; this.flags = data.flags; this.guildID = guildID; this.hoist = !!data.hoist; @@ -57,6 +64,13 @@ export default class Role extends Base { if (data.color !== undefined) { this.color = data.color; } + if (data.colors !== undefined) { + this.colors = { + primaryColor: data.colors.primary_color, + secondaryColor: data.colors.secondary_color, + tertiaryColor: data.colors.tertiary_color + }; + } if (data.hoist !== undefined) { this.hoist = data.hoist; } @@ -132,6 +146,7 @@ export default class Role extends Base { return { ...super.toJSON(), color: this.color, + colors: this.colors, guildID: this.guildID, hoist: this.hoist, icon: this.icon, diff --git a/lib/structures/User.ts b/lib/structures/User.ts index 1b76aa96..9e593897 100644 --- a/lib/structures/User.ts +++ b/lib/structures/User.ts @@ -7,7 +7,7 @@ import Clan from "./Clan"; import { EntitlementOwnerTypes, type ImageFormat } from "../Constants"; import * as Routes from "../util/Routes"; import type Client from "../Client"; -import type { AvatarDecorationData, RawUser } from "../types/users"; +import type { AvatarDecorationData, Collectibles, RawUser } from "../types/users"; import type { JSONUser } from "../types/json"; import type { SearchEntitlementsOptions } from "../types/applications"; import { UncachedError } from "../util/Errors"; @@ -26,6 +26,8 @@ export default class User extends Base { bot: boolean; /** The primary clan this user is in. */ clan: Clan | null; + /** The user's collectibles. */ + collectibles: Collectibles | null; /** The 4 digits after this user's username, if they have not been migrated. If migrated, this will be a single "0". */ discriminator: string; /** The user's display name, if set. */ @@ -42,6 +44,7 @@ export default class User extends Base { this.avatarDecorationData = null; this.bot = !!data.bot; this.clan = null; + this.collectibles = null; this.discriminator = data.discriminator; this.globalName = data.global_name; this.publicFlags = 0; @@ -66,6 +69,16 @@ export default class User extends Base { if (data.banner !== undefined) { this.banner = data.banner; } + if (data.collectibles !== undefined) { + this.collectibles = data.collectibles ? { + nameplate: data.collectibles.nameplate ? { + asset: data.collectibles.nameplate.asset, + label: data.collectibles.nameplate.label, + palette: data.collectibles.nameplate.palette, + skuID: data.collectibles.nameplate.sku_id + } : undefined + } : null; + } if (data.discriminator !== undefined) { this.discriminator = data.discriminator; } @@ -185,6 +198,7 @@ export default class User extends Base { avatarDecorationData: this.avatarDecorationData, banner: this.banner, bot: this.bot, + collectibles: this.collectibles, discriminator: this.discriminator, globalName: this.globalName, publicFlags: this.publicFlags, diff --git a/lib/types/guilds.d.ts b/lib/types/guilds.d.ts index 3595ba81..1c9e7b4d 100644 --- a/lib/types/guilds.d.ts +++ b/lib/types/guilds.d.ts @@ -109,6 +109,7 @@ export interface RawInviteGuild extends Pick> { id: string; user?: RawUser; } export interface GuildEmoji extends Omit { id: string; requireColons?: boolean; user?: User; } export interface RawWelcomeScreen { diff --git a/lib/types/json.d.ts b/lib/types/json.d.ts index a2a50deb..1aaaf5f2 100644 --- a/lib/types/json.d.ts +++ b/lib/types/json.d.ts @@ -20,7 +20,8 @@ import type { WelcomeScreen, Sticker, Presence, - IncidentActions + IncidentActions, + RoleColors } from "./guilds"; import type { ChannelMention, @@ -46,7 +47,7 @@ import type { MessageComponent } from "./channels"; import type { ScheduledEventEntityMetadata } from "./scheduled-events"; -import type { AvatarDecorationData } from "./users"; +import type { AvatarDecorationData, Collectibles } from "./users"; import type { ApplicationCommandTypes, AutoModerationEventTypes, @@ -635,6 +636,7 @@ export interface JSONPublicThreadChannel extends JSONThreadChannel { } export interface JSONRole extends JSONBase { color: number; + colors: RoleColors; guildID: string; hoist: boolean; icon: string | null; @@ -755,6 +757,7 @@ export interface JSONUser extends JSONBase { avatarDecorationData: AvatarDecorationData | null; banner?: string | null; bot: boolean; + collectibles: Collectibles | null; discriminator: string; globalName: string | null; publicFlags: number; diff --git a/lib/types/users.d.ts b/lib/types/users.d.ts index 843bcc5d..5507088f 100644 --- a/lib/types/users.d.ts +++ b/lib/types/users.d.ts @@ -9,6 +9,7 @@ export interface RESTUser { banner?: string | null; bot?: boolean; clan?: RawClan | null; + collectibles?: RawCollectibles | null; discriminator: string; email?: string | null; flags?: number; @@ -23,7 +24,7 @@ export interface RESTUser { username: string; verified?: boolean; } -export interface RawUser extends Pick, Required> {} +export interface RawUser extends Pick, Required> {} export interface RawUserWithMember extends RawUser, Pick {} export interface RawOAuthUser extends Pick, Required> {} export interface RawExtendedUser extends Pick {} @@ -60,3 +61,25 @@ export interface AvatarDecorationData { asset: string; skuID: string; } + +export interface RawCollectibles { + nameplate?: RawNameplate; +} + +export interface Collectibles { + nameplate?: Nameplate; +} + +export interface RawNameplate { + asset: string; + label: string; + palette: string; + sku_id: string; +} + +export interface Nameplate { + asset: string; + label: string; + palette: string; + skuID: string; +}