From 18d7fe8caabc7216855c1213c1a669a34193645e Mon Sep 17 00:00:00 2001 From: qwerinope Date: Wed, 25 Jun 2025 22:21:00 +0200 Subject: [PATCH] prepare item management --- bot/items/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot/items/index.ts b/bot/items/index.ts index 12e30f3..01931d0 100644 --- a/bot/items/index.ts +++ b/bot/items/index.ts @@ -31,12 +31,16 @@ export class Item { import { readdir } from 'node:fs/promises'; const items = new Map; const itemintents: string[] = []; +const emptyInventory = {}; +const itemarray: string[] = []; const files = await readdir(import.meta.dir); for (const file of files) { if (!file.endsWith('.ts')) continue; if (file === import.meta.file) continue; const item: Item = await import(import.meta.dir + '/' + file.slice(0, -3)).then(a => a.default); + Object.defineProperty(emptyInventory, item.name, { value: 0 }); + itemarray.push(item.name); itemintents.push(...item.requiredIntents); for (const alias of item.aliases) { items.set(alias, item); // Since it's not a primitive type the map is filled with references to the item, not the actual object @@ -44,4 +48,4 @@ for (const file of files) { }; export default items; -export { itemintents }; +export { itemintents, emptyInventory, itemarray };