Files
aurorabot/shared/lib/rarity.ts
syntaxbullet 782a138fd8
All checks were successful
Deploy to Production / test (push) Successful in 36s
fix: strip query params from asset URLs before filesystem lookup
Icon URLs stored with cache-busting query params (e.g. ?v=123) caused
existsSync to fail, preventing Discord attachment fallback and leaving
unresolvable localhost URLs as thumbnails.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 15:48:19 +01:00

29 lines
1.2 KiB
TypeScript

/**
* Shared Rarity Configuration
* Provides the canonical rarity display config (colors, emoji, labels)
* used by lootbox pull results and shop loot table views.
*/
export const RARITY_CONFIG: Record<string, { color: number; emoji: string; label: string }> = {
C: { color: 0x95A5A6, emoji: "📦", label: "Common" },
R: { color: 0x3498DB, emoji: "📦", label: "Rare" },
SR: { color: 0x9B59B6, emoji: "✨", label: "Super Rare" },
SSR: { color: 0xF1C40F, emoji: "🌟", label: "SSR" },
CURRENCY: { color: 0x2ECC71, emoji: "💰", label: "Currency" },
XP: { color: 0x1ABC9C, emoji: "🔮", label: "Experience" },
NOTHING: { color: 0x636363, emoji: "💨", label: "Empty" },
};
export function getRarityConfig(rarity: string): { color: number; emoji: string; label: string } {
return RARITY_CONFIG[rarity] ?? (RARITY_CONFIG["C"]!);
}
export function defaultName(path: string): string {
return stripQuery(path).split("/").pop() || "image.png";
}
/** Strip query parameters from a URL/path (e.g. "foo.png?v=123" → "foo.png") */
export function stripQuery(url: string): string {
const idx = url.indexOf("?");
return idx === -1 ? url : url.slice(0, idx);
}