# Feather Bot 3.2.1

Changelog covers the 5-minute background Bazaar history sync service (`utils/bazaarSync.js`), 0ms Bazaar item detail lookups eliminating HTTP 429 rate limits, minion upgrade cost calculator integration (`commands/minion.js`), Discord API Error 50035 component serialization fixes (`index.js`), LRU session token cache expansion (`utils/cache.js`), `/custom price` and `/custom npcprice` slash command suite (`commands/custom.js`), operator-based permission scoping (`utils/opStore.js`), strict NPC merchant trade database cleanup (`data/npcPrices.json`), and accessory checklist & multi-inventory scanning overhaul (`data/accessoryChecklist.js` & `commands/assesories.js`).

## Detailed Summary

Version 3.2.1 is a targeted stability and feature release addressing rate-limit price inflation, Discord component serialization errors, session token cache eviction, operator command management, NPC merchant price accuracy, and accessory checklist tracking.

The **5-Minute Bazaar History Background Sync & 0ms Rate Limit Fix** (`utils/bazaarSync.js` & `utils/bazaarApi.js`):
- Implemented background synchronization service (`startBazaarHistorySync`) that fetches `https://bazaar.craftersmcguides.workers.dev/api/items/history` every 5 minutes and saves a complete item snapshot to `data/bazaar-history.json`.
- Updated `fetchItemDetailsSafe` and `fetchCatalogProducts` in `utils/bazaarApi.js` to read directly from the in-memory history map (`getBazaarHistoryItem`) in **0ms**, completely resolving HTTP 429 rate limit errors and preventing 200B+ networth price inflation.

The **Minion Calculator Upgrade Cost Optimization** (`commands/minion.js`):
- Updated `/minion upgrade cost` and `/minion upgrades` to resolve Bazaar ingredient prices from `data/bazaar-history.json` and verified NPC shop prices.
- Instant 0ms ingredient price resolution across all minion upgrade tiers without external API delays.

The **Discord API Error 50035 & Session Token Preservation** (`index.js` & `utils/cache.js`):
- Refactored `disableInteractiveComponents` in `index.js` using `component.toJSON()`, preserving `type: 1` (`ActionRow`) on disabled message controls and eliminating `DiscordAPIError[50035]: Field "type" is required`.
- Resolved `components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (1,)` in `/custom` by combining `ContainerBuilder` with `MessageFlags.IsComponentsV2`.
- Increased `MAX_ENTRIES` in `utils/cache.js` from 50 to 2000 and implemented two-pass LRU eviction protecting active session keys (`pvctx:`, `ivctx:`, `refresh:`, `mupg:`, `cpcctx:`, etc.) from expiring prematurely while in use.

The **`/custom price` & `/custom npcprice` Subcommands Suite** (`commands/custom.js`, `utils/customPrices.js`, `data/npcPrices.js`):
- Implemented `/custom price add`, `/custom price modify`, `/custom price delete`, and `/custom price list` for managing custom static item prices in `data/customPrices.js`.
- Implemented `/custom npcprice add`, `/custom npcprice modify`, `/custom npcprice delete`, and `/custom npcprice list` for managing NPC merchant sell prices in `data/npcPrices.json`.
- Added interactive, paginated directory displays with `◀ Prev`, `Page X/Y`, and `Next ▶` buttons.
- Enforced runtime `isOp(interaction.user.id)` check against `utils/opStore.js` (`OWNER_ID`, `OPS`, `OP_IDS`, `BOT_OPS` in `.env`) and set `.setDefaultMemberPermissions(null)` so bot operators can execute `/custom` regardless of Discord server administrator roles.

The **NPC Merchant Shop Database Cleanup** (`data/npcPrices.json` & `data/NPC_trades.txt`):
- Cleaned `data/npcPrices.json` to strictly align with the 155 verified NPC shop trades from `data/NPC_trades.txt`, purging 340+ bloated/synthetic enchanted item entries.

The **Accessory Checklist & Multi-Inventory Scanning Overhaul** (`data/accessoryChecklist.js` & `commands/assesories.js`):
- Updated `data/accessoryChecklist.js` to include complete tier upgrade families: **Intimidation** (`Intimidation Talisman » Intimidation Ring » Intimidation Artifact`), **Bat**, **Bat Person**, and **Candy**.
- Updated `normalizeAccessoryName` to strip Minecraft color codes `§.` and bracketed/parenthetical metadata (`[0 Kills]`, `[1,250 Kills]`), fixing **Blood God Crest** detection.
- Expanded `/accessories` scanner to combine items across `accessoryBag`, `inventory`, `enderChest`, `armor`, and `vault`.

## Added

- Added `utils/bazaarSync.js` providing `startBazaarHistorySync`, `fetchBazaarHistoryAndSave`, and `getBazaarHistoryItem`.
- Added `/custom price add`, `/custom price modify`, `/custom price delete`, and `/custom price list` subcommands in `commands/custom.js`.
- Added `/custom npcprice add`, `/custom npcprice modify`, `/custom npcprice delete`, and `/custom npcprice list` subcommands in `commands/custom.js`.
- Added `deleteCustomPrice` export in `utils/customPrices.js`.
- Added `saveNpcPrice` and `deleteNpcPrice` exports in `data/npcPrices.js`.
- Added missing accessory tier families (**Bat**, **Bat Person**, **Candy**, and **Intimidation**) in `data/accessoryChecklist.js`.

## Changed

- Updated `fetchItemDetailsSafe` in `utils/bazaarApi.js` to read from local `bazaar-history.json` snapshot in 0ms.
- Updated `/minion upgrade cost` (`commands/minion.js`) to use 0ms local Bazaar history snapshot and `getNpcSellPrice`.
- Updated `CACHE_MAX_ENTRIES` in `utils/cache.js` from 50 to 2000 and protected session keys in `trimToLimit`.
- Updated `/custom` slash command permissions (`commands/custom.js`) to `.setDefaultMemberPermissions(null)` with runtime `isOp` enforcement.
- Cleaned `data/npcPrices.json` down to the 155 verified NPC shop trades listed in `data/NPC_trades.txt`.
- Expanded `/accessories` item scanner (`commands/assesories.js`) to gather accessories across `accessoryBag`, `inventory`, `enderChest`, `armor`, and `vault`.
- Updated `normalizeAccessoryName` in `data/accessoryChecklist.js` to strip bracketed/parenthetical kill count suffixes (`[0 Kills]`).

## Fixed

- Fixed HTTP 429 rate-limiting and 200B+ price inflation on `/networth` and `/item` by serving Bazaar item details locally.
- Fixed `DiscordAPIError[50035]: Field "type" is required` when disabling expired message controls in `index.js`.
- Fixed `DiscordAPIError[50035]: Value of field "type" must be one of (1,)` in `/custom` button responses by using `ContainerBuilder` with `MessageFlags.IsComponentsV2`.
- Fixed active user interaction sessions (`pvctx:`, `ivctx:`, `refresh:`, `mupg:`, etc.) expiring prematurely due to LRU cache eviction.
- Fixed `saveCustomPrice` insertion in `utils/customPrices.js` targeting `const CUSTOM_PRICES` block explicitly instead of appending into `CUSTOM_PRICE_NAMES`.
- Fixed **Blood God Crest** reporting missing when present in player's accessory bag or inventory due to bracketed kill count suffixes.
- Fixed **Intimidation Artifact** and **Intimidation Ring** not fulfilling the `Intimidation Talisman` checklist requirement.
