From 305a0b0553aff1290e5c5d486e634b3d41e83251 Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Wed, 18 Mar 2026 22:01:05 +0100 Subject: [PATCH] fix: collapse double find() and add <0.1% guard for tiny drop rates Co-Authored-By: Claude Opus 4.6 (1M context) --- bot/modules/economy/shop.view.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bot/modules/economy/shop.view.ts b/bot/modules/economy/shop.view.ts index b330ed8..47e63a5 100644 --- a/bot/modules/economy/shop.view.ts +++ b/bot/modules/economy/shop.view.ts @@ -106,8 +106,8 @@ export function getShopListingMessage( .setEmoji("🛒"); // 2. Loot Table (if applicable) — separate Container with blurple accent - if (item.usageData?.effects?.find((e: any) => e.type === EffectType.LOOTBOX)) { - const lootboxEffect = item.usageData.effects.find((e: any) => e.type === EffectType.LOOTBOX); + const lootboxEffect = item.usageData?.effects?.find((e: any) => e.type === EffectType.LOOTBOX); + if (lootboxEffect) { const pool = lootboxEffect.pool as LootTableItem[]; const totalWeight = pool.reduce((sum: number, i: LootTableItem) => sum + i.weight, 0); @@ -181,7 +181,7 @@ export function getShopListingMessage( isFirst = false; const config = getRarityConfig(rarity); - const chanceStr = tier.totalChance.toFixed(1); + const chanceStr = tier.totalChance < 0.1 ? "<0.1" : tier.totalChance.toFixed(1); lootContainer.addTextDisplayComponents( new TextDisplayBuilder().setContent( `${config.emoji} **${config.label}** — ${chanceStr}%`