commit
try new userframes
diff --git a/src/discord/constants.ts b/src/discord/constants.ts
index 14a7c87..6946a8f 100644
--- a/src/discord/constants.ts
+++ b/src/discord/constants.ts
@@ -206,6 +206,11 @@ export function collectibleTypeName(type: number | null | undefined): WishlistIt
return "profile_effect";
case 2:
return "nameplate";
+ case 3:
+ // Profile Frames — new Shop collectible (mid-2026). Type id inferred as
+ // the next sequential value; the slot-name fallback below covers us if
+ // Discord picked a different number.
+ return "profile_frame";
case 1000:
return "bundle";
case 2000:
@@ -217,6 +222,28 @@ export function collectibleTypeName(type: number | null | undefined): WishlistIt
}
}
+/**
+ * Map a `collectibles` blob slot key ("nameplate", "profile_frame", …) to our
+ * kind. Used as a fallback when the resolved product's numeric type isn't one
+ * we recognise yet, so a newly-added collectible slot still gets a sensible
+ * kind instead of "unknown". Unknown slots pass through as-is.
+ */
+export function collectibleSlotType(slot: string): WishlistItemType {
+ switch (slot) {
+ case "avatar_decoration":
+ return "avatar_decoration";
+ case "profile_effect":
+ return "profile_effect";
+ case "nameplate":
+ return "nameplate";
+ case "profile_frame":
+ case "frame":
+ return "profile_frame";
+ default:
+ return "unknown";
+ }
+}
+
/** Static preset image for an avatar decoration (APNG served at .png). */
export function avatarDecorationImageUrl(asset: string): string {
return `${CDN}/avatar-decoration-presets/${asset}.png`;
diff --git a/src/discord/rest.ts b/src/discord/rest.ts
index 708ed62..92bbbbb 100644
--- a/src/discord/rest.ts
+++ b/src/discord/rest.ts
@@ -23,7 +23,7 @@ function apiBase(env: Env): string {
// Matched to a real Firefox web client (stable channel). Keep these in sync with
// an actual client's X-Super-Properties — re-grab and bump when they drift.
const BROWSER_UA =
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0";
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko/20100101 Firefox/152.0";
// A real web client also sends these per-"launch" identifiers. Discord doesn't
// appear to validate them (Dustin runs static ones fine for months), so we mint
@@ -46,19 +46,19 @@ function getLaunchIdentity() {
}
function superProperties(env: Env): string {
- const build = Number(env.DISCORD_CLIENT_BUILD_NUMBER || "565311");
+ const build = Number(env.DISCORD_CLIENT_BUILD_NUMBER || "579073");
// Field set matched to a real Firefox WEB client. Do NOT add desktop-only
// fields (native_build_number, os_arch, X-Installation-ID, …) — a "Firefox"
// client that claims those is inconsistent and reads as MORE suspicious.
const props = {
- os: "Windows",
+ os: "Mac OS X",
browser: "Firefox",
device: "",
system_locale: "en-GB",
has_client_mods: false,
browser_user_agent: BROWSER_UA,
browser_version: "152.0",
- os_version: "10",
+ os_version: "10.15",
referrer: "",
referring_domain: "",
referrer_current: "",
@@ -285,6 +285,86 @@ export async function fetchWishlist(env: Env, wishlistId: string): Promise<Wishl
}
+// ---- collectibles products (resolve an equipped collectible's SKU) -------
+// The rich profile's `collectibles` blob only carries SKU ids (+ a little
+// metadata) per slot — nameplate, and since mid-2026 the new `profile_frame`.
+// GET /collectibles-products/{sku_id} resolves one of those SKUs into a full
+// product (name, summary, styles, and an `items[]` array whose entries carry
+// ready-made static/animated/video asset URLs). Same fingerprint trick as the
+// profile call so we get the client's gentler rate limits; bot token fallback.
+
+/** One resolved item inside a collectible product (avatar deco / effect /
+ * nameplate / frame). Only the fields we surface are typed; the rest ride
+ * along untyped so a brand-new item kind still passes through. */
+export interface RawCollectibleItem {
+ type?: number;
+ id?: string;
+ sku_id?: string;
+ asset?: string;
+ label?: string;
+ palette?: string;
+ title?: string;
+ description?: string;
+ accessibilityLabel?: string;
+ assets?: {
+ static_image_url?: string | null;
+ animated_image_url?: string | null;
+ video_url?: string | null;
+ } | null;
+ // profile-effect image fields live directly on the item
+ staticFrameSrc?: string | null;
+ thumbnailPreviewSrc?: string | null;
+ reducedMotionSrc?: string | null;
+ [k: string]: unknown;
+}
+
+export interface RawCollectibleProduct {
+ sku_id?: string;
+ store_listing_id?: string;
+ type?: number;
+ name?: string;
+ summary?: string;
+ items?: RawCollectibleItem[];
+ [k: string]: unknown;
+}
+
+/**
+ * Resolve one collectible SKU to its product. User token + client fingerprint
+ * first (better rate limits, and some collectibles are gated to it), bot token
+ * as a fallback; configured API version then v10. null on failure.
+ */
+export async function fetchCollectibleProduct(
+ env: Env,
+ skuId: string
+): Promise<RawCollectibleProduct | null> {
+ const configured = env.DISCORD_API_VERSION || "10";
+ const versions = configured === "10" ? ["10"] : [configured, "10"];
+ const tokens = userTokens(env);
+ const locale = "en-GB";
+
+ for (const ver of versions) {
+ const url =
+ `https://discord.com/api/v${ver}/collectibles-products/${skuId}` +
+ `?locale=${locale}`;
+ for (let i = 0; i < tokens.length; i++) {
+ const r = await tryJson(url, clientHeaders(env, tokens[i]), `collectible ${skuId} v${ver} user#${i + 1}`);
+ if (r.raw) return r.raw as RawCollectibleProduct;
+ // 404/429 → try next token/version; anything else → give up this version.
+ if (r.status !== 429 && r.status !== 404) break;
+ }
+ if (env.DISCORD_BOT_TOKEN) {
+ const rb = await tryJson(
+ url,
+ { Authorization: `Bot ${env.DISCORD_BOT_TOKEN}` },
+ `collectible ${skuId} v${ver} bot`
+ );
+ if (rb.raw) return rb.raw as RawCollectibleProduct;
+ }
+ }
+ return null;
+}
+
+
// ---- guild roles / members (for /v1/girls/:idType/:id) -------------------
export interface RawGuildRole {
diff --git a/src/index.ts b/src/index.ts
index 66f337b..42d3338 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -122,6 +122,7 @@ function buildRecord(
clientBadges: profile.clientBadges,
connected_accounts: profile.connected_accounts,
wishlist: profile.wishlist ?? null,
+ collectibles_resolved: profile.collectibles_resolved ?? null,
mutual_guilds: profile.mutual_guilds ?? null,
mutual_friends: profile.mutual_friends ?? null,
mutual_friends_count: profile.mutual_friends_count ?? null,
diff --git a/src/profile.ts b/src/profile.ts
index 193cd82..c6c2aaf 100644
--- a/src/profile.ts
+++ b/src/profile.ts
@@ -16,6 +16,7 @@ import type {
UnifiedMutualGuild,
UnifiedPremium,
UnifiedReviews,
+ UnifiedCollectible,
UnifiedTimezone,
UnifiedUser,
UnifiedWishlistItem,
@@ -28,6 +29,7 @@ import {
bannerUrl,
CDN,
clanBadgeUrl,
+ collectibleSlotType,
collectibleTypeName,
decodeUserFlags,
decorationUrl,
@@ -39,9 +41,12 @@ import {
} from "./discord/constants";
import {
fetchBotUser,
+ fetchCollectibleProduct,
fetchGuildBasic,
fetchUserProfile,
fetchWishlist,
+ type RawCollectibleItem,
+ type RawCollectibleProduct,
type RawDiscordUser,
type RawMutualFriend,
type RawMutualGuild,
@@ -60,6 +65,9 @@ export interface ProfileResult {
connected_accounts: UnifiedConnectedAccount[];
/** Shop collectibles saved to the profile; null when unavailable. */
wishlist: UnifiedWishlistItem[] | null;
+ /** Collectibles the user has EQUIPPED (nameplate, profile frame, …),
+ * resolved to names + assets; null when unavailable. */
+ collectibles_resolved: UnifiedCollectible[] | null;
/** Guilds shared with the userbot account (rich profile). */
mutual_guilds: UnifiedMutualGuild[] | null;
/** Friends shared with the userbot account (rich profile). */
@@ -399,6 +407,157 @@ async function buildWishlist(
return out;
}
+// ---- equipped collectibles (profile's `collectibles` blob) --------------
+// The rich profile carries a `collectibles` map: slot -> { sku_id, … } for
+// whatever the user has EQUIPPED (nameplate, and since mid-2026 the new
+// `profile_frame`). Unlike the wishlist, the blob only has SKU ids, so we
+// resolve each via GET /collectibles-products/{sku_id} to get names + assets.
+// Written generically over the slot keys so a new collectible type surfaces
+// without a code change.
+
+/** KV key for a resolved collectible product (global, shared across viewers). */
+function collectibleKey(skuId: string): string {
+ return `collectible:${skuId}`;
+}
+
+/** Fetch + cache one collectible product by SKU id (~1h; products are stable). */
+async function getCollectibleProduct(
+ env: Env,
+ skuId: string,
+ ctx?: ExecutionContext,
+ force = false
+): Promise<RawCollectibleProduct | null> {
+ if (!force) {
+ const cached = (await env.PROFILE_CACHE.get(collectibleKey(skuId), "json")) as
+ | RawCollectibleProduct
+ | null;
+ if (cached) return cached;
+ }
+ const raw = await fetchCollectibleProduct(env, skuId);
+ if (!raw) return null;
+ const write = env.PROFILE_CACHE.put(collectibleKey(skuId), JSON.stringify(raw), {
+ expirationTtl: 3600,
+ });
+ if (ctx) ctx.waitUntil(write);
+ else await write;
+ return raw;
+}
+
+/** Pick the item from a product that matches the slot (else the first item). */
+function pickCollectibleItem(
+ product: RawCollectibleProduct | null,
+ slot: string
+): RawCollectibleItem | null {
+ const items = Array.isArray(product?.items) ? product!.items! : [];
+ if (!items.length) return null;
+ const want = collectibleSlotType(slot);
+ const match = items.find((it) => collectibleTypeName(it?.type) === want);
+ return match ?? items[0];
+}
+
+/** Resolve static/animated/video URLs for one equipped collectible. Prefers the
+ * product item's ready-made `assets`; falls back to constructing them from the
+ * asset path (so a product-lookup failure still yields nameplate/deco art). */
+function collectibleImages(
+ item: RawCollectibleItem | null,
+ slot: string,
+ blobAsset: string | undefined
+): Pick<UnifiedCollectible, "static_image_url" | "animated_image_url" | "video_url"> {
+ const a = (item && item.assets) || {};
+ let stat: string | null = a.static_image_url ?? null;
+ let anim: string | null = a.animated_image_url ?? null;
+ let vid: string | null = a.video_url ?? null;
+ if (!stat && !anim && !vid) {
+ const type = item?.type;
+ const asset = item?.asset ?? blobAsset;
+ if ((type === 2 || slot === "nameplate") && asset) {
+ // nameplate — still PNG + WEBM under /assets/collectibles/
+ stat = nameplateStaticUrl(asset);
+ vid = nameplateVideoUrl(asset);
+ } else if (type === 0 && asset) {
+ // avatar decoration — APNG served at .png
+ stat = avatarDecorationImageUrl(asset);
+ anim = avatarDecorationImageUrl(asset);
+ } else if (type === 1) {
+ // profile effect — image fields are full URLs on the item itself
+ stat = item?.staticFrameSrc ?? item?.thumbnailPreviewSrc ?? null;
+ anim = item?.thumbnailPreviewSrc ?? item?.reducedMotionSrc ?? null;
+ }
+ // profile_frame (+ any future kind): assets arrive as full URLs on the
+ // product item, so if those were absent there's nothing to reconstruct.
+ }
+ return { static_image_url: stat, animated_image_url: anim, video_url: vid };
+}
+
+/**
+ * Build the equipped-collectibles list from the rich profile's `collectibles`
+ * blob. Iterates every slot with a `sku_id`, resolves the product, and maps it
+ * to a UnifiedCollectible. Returns null when the blob is absent (so a bot-only
+ * refresh keeps the cached list); [] when the profile has no equipped
+ * collectibles. A per-item product-lookup failure still emits an entry built
+ * from the blob's own fields rather than dropping the equipped item.
+ */
+async function buildCollectibles(
+ env: Env,
+ rawCollectibles: Record<string, unknown> | null | undefined,
+ ctx?: ExecutionContext,
+ force = false
+): Promise<UnifiedCollectible[] | null> {
+ if (!rawCollectibles || typeof rawCollectibles !== "object") return null;
+ const entries = Object.entries(rawCollectibles).filter(
+ ([, v]) => v && typeof v === "object"
+ );
+ if (!entries.length) return [];
+
+ const out: UnifiedCollectible[] = [];
+ for (const [slot, vRaw] of entries) {
+ const v = vRaw as Record<string, any>;
+ const skuId = typeof v.sku_id === "string" ? v.sku_id : null;
+ if (!skuId) continue;
+
+ const product = await getCollectibleProduct(env, skuId, ctx, force);
+ const item = pickCollectibleItem(product, slot);
+
+ const typeId =
+ typeof item?.type === "number"
+ ? item.type
+ : typeof product?.type === "number"
+ ? product.type
+ : null;
+ let kind = collectibleTypeName(typeId);
+ if (kind === "unknown") kind = collectibleSlotType(slot);
+
+ const images = collectibleImages(
+ item,
+ slot,
+ typeof v.asset === "string" ? v.asset : undefined
+ );
+
+ out.push({
+ slot,
+ sku_id: skuId,
+ type: kind,
+ type_id: typeId,
+ name: product?.name ?? item?.title ?? null,
+ summary: product?.summary ?? item?.description ?? null,
+ label:
+ (typeof v.label === "string" ? v.label : null) ??
+ item?.label ??
+ item?.accessibilityLabel ??
+ null,
+ ...images,
+ palette:
+ typeof v.palette === "string"
+ ? v.palette
+ : typeof item?.palette === "string"
+ ? item.palette
+ : null,
+ expires_at: typeof v.expires_at === "number" ? v.expires_at : null,
+ });
+ }
+ return out;
+}
+
function cacheKey(id: string): string {
return `profile:${id}`;
}
@@ -467,6 +626,11 @@ export async function getProfile(
if (built.wishlist == null && cached?.wishlist != null) {
built.wishlist = cached.wishlist;
}
+ // Same for equipped collectibles — a 429 on the product lookups shouldn't
+ // wipe a previously resolved list.
+ if (built.collectibles_resolved == null && cached?.collectibles_resolved != null) {
+ built.collectibles_resolved = cached.collectibles_resolved;
+ }
const write = writeCache(env, id, built);
if (ctx) ctx.waitUntil(write);
else await write;
@@ -507,6 +671,9 @@ function mergeRichOverBot(cached: CachedProfile, bot: ProfileResult): CachedProf
// Bot-only refreshes can't read the wishlist / mutuals (they ride on the
// rich profile), so keep the cached ones rather than dropping to null.
wishlist: bot.wishlist != null ? bot.wishlist : cached.wishlist,
+ // Equipped collectibles ride on the rich profile too — keep the cached list.
+ collectibles_resolved:
+ bot.collectibles_resolved != null ? bot.collectibles_resolved : cached.collectibles_resolved,
mutual_guilds: cached.mutual_guilds,
mutual_friends: cached.mutual_friends,
mutual_friends_count: cached.mutual_friends_count,
@@ -530,6 +697,7 @@ async function writeCache(env: Env, id: string, result: ProfileResult): Promise<
clientBadges: result.clientBadges,
connected_accounts: result.connected_accounts,
wishlist: result.wishlist,
+ collectibles_resolved: result.collectibles_resolved,
mutual_guilds: result.mutual_guilds,
mutual_friends: result.mutual_friends,
mutual_friends_count: result.mutual_friends_count,
@@ -611,16 +779,25 @@ async function buildFreshProfile(
// Fetch everything that doesn't depend on the profile body in parallel.
// Wishlist + mutual guilds need the profile, so they run alongside.
- const [wishlist, clientBadges, mutualGuilds, memberships, pronoundb, timezone, reviews] =
- await Promise.all([
- buildWishlist(env, profile, ctx, force),
- getClientBadges(env, id, ctx, force),
- buildMutualGuilds(env, profile.mutual_guilds, ctx),
- getMemberships(env, id, ctx, force).catch(() => null),
- getPronouns(env, id, ctx, force).catch(() => null),
- getTimezone(env, id, ctx, force).catch(() => null),
- getReviews(env, id, ctx, force).catch(() => null),
- ]);
+ const [
+ wishlist,
+ collectiblesResolved,
+ clientBadges,
+ mutualGuilds,
+ memberships,
+ pronoundb,
+ timezone,
+ reviews,
+ ] = await Promise.all([
+ buildWishlist(env, profile, ctx, force),
+ buildCollectibles(env, u.collectibles as Record<string, unknown> | null, ctx, force),
+ getClientBadges(env, id, ctx, force),
+ buildMutualGuilds(env, profile.mutual_guilds, ctx),
+ getMemberships(env, id, ctx, force).catch(() => null),
+ getPronouns(env, id, ctx, force).catch(() => null),
+ getTimezone(env, id, ctx, force).catch(() => null),
+ getReviews(env, id, ctx, force).catch(() => null),
+ ]);
return {
result: {
@@ -630,6 +807,7 @@ async function buildFreshProfile(
clientBadges,
connected_accounts: connected,
wishlist,
+ collectibles_resolved: collectiblesResolved,
mutual_guilds: mutualGuilds,
mutual_friends: buildMutualFriends(profile.mutual_friends),
mutual_friends_count:
@@ -667,6 +845,7 @@ async function buildFreshProfile(
clientBadges,
connected_accounts: [],
wishlist: null,
+ collectibles_resolved: null,
mutual_guilds: null,
mutual_friends: null,
mutual_friends_count: null,
diff --git a/src/types.ts b/src/types.ts
index 13b6f3d..37ab006 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -158,11 +158,49 @@ export type WishlistItemType =
| "avatar_decoration"
| "profile_effect"
| "nameplate"
+ | "profile_frame"
| "bundle"
| "variants_group"
| "external_sku"
| "unknown";
+/**
+ * One collectible a user has EQUIPPED on their profile, resolved from the
+ * `collectibles` blob on the (rich) profile. Discord returns that blob as a map
+ * of slot -> { sku_id, ... } (e.g. `nameplate`, and — since mid-2026 — the new
+ * `profile_frame` Shop collectible). We resolve each slot's SKU via
+ * GET /collectibles-products/{sku_id} to get its name + image assets, so the
+ * frontend can render whatever the user is wearing without knowing the slot
+ * names ahead of time. Forward-compatible: an unrecognised slot still resolves.
+ */
+export interface UnifiedCollectible {
+ /** The slot key from the profile's collectibles blob ("nameplate",
+ * "profile_frame", …). Passed through raw so new slots surface immediately. */
+ slot: string;
+ /** SKU id of the equipped collectible product. */
+ sku_id: string;
+ /** Human-readable kind resolved from the product's numeric type. */
+ type: WishlistItemType;
+ /** Raw Discord numeric product type (0/1/2/…); null if unresolved. */
+ type_id: number | null;
+ /** Product name, e.g. "Angel" (null if the product lookup failed). */
+ name: string | null;
+ /** Short product description/summary when present. */
+ summary: string | null;
+ /** Accessibility label / alt text from Discord. */
+ label: string | null;
+ /** Still image (PNG / APNG first frame). */
+ static_image_url: string | null;
+ /** Animated image (APNG) when the collectible animates. */
+ animated_image_url: string | null;
+ /** Video preview (WEBM/MP4) when present. */
+ video_url: string | null;
+ /** Nameplate colour palette (e.g. "bubble_gum"); null for other kinds. */
+ palette: string | null;
+ /** Unix timestamp (seconds) the equipped item expires; null if permanent. */
+ expires_at: number | null;
+}
+
/**
* One Discord Shop collectible a user has saved to their profile wishlist.
* The SKU + per-user settings come from the profile's `wishlist_settings`; the
@@ -369,6 +407,11 @@ export interface UnifiedRecord {
* null when unavailable (no user token / proxy, or the source was blocked);
* [] means we reached the source and the wishlist is empty. */
wishlist: UnifiedWishlistItem[] | null;
+ /** Collectibles the user has EQUIPPED (nameplate, profile frame, …), resolved
+ * from the rich profile's `collectibles` blob to names + image assets.
+ * null when unavailable (no user token, or the source was blocked);
+ * [] means the profile was reachable but nothing is equipped. */
+ collectibles_resolved: UnifiedCollectible[] | null;
/** Guilds shared with the userbot account (rich profile, with_mutual_guilds).
* null when unavailable; [] when none. */
mutual_guilds: UnifiedMutualGuild[] | null;
diff --git a/wrangler.jsonc b/wrangler.jsonc
index 73345ec..b434c70 100644
--- a/wrangler.jsonc
+++ b/wrangler.jsonc
@@ -59,7 +59,7 @@
"DISCORD_API_VERSION": "9",
"TRACKED_GUILD_IDS": "",
"PROFILE_CACHE_TTL_SECONDS": "1800",
- "DISCORD_CLIENT_BUILD_NUMBER": "565311",
+ "DISCORD_CLIENT_BUILD_NUMBER": "579073",
"GIRLS_GUILD_ID": "1498839518265213069",
// Guilds to resolve per-user membership for (roles/join/boost/nick/avatar/
// timeout). Empty falls back to TRACKED_GUILD_IDS; empty there = skipped.