diff --git a/commands/buy.ts b/commands/buy.ts index 5e1d2d4..26b8685 100644 --- a/commands/buy.ts +++ b/commands/buy.ts @@ -15,7 +15,7 @@ async function run(interaction: ChatInputCommandInteraction, user: User) { if (quantity <= 0) throw new BotError("Can't buy 0 or less of an item. Nice try"); const item = await get_item(name); if (!item) throw new BotError("Item does not exist"); - if (!item.price) throw new BotError("Item is not buyable"); + if (item.price === null) throw new BotError("Item is not buyable"); if (item.roles_required.length > 0) { for (const role_id of item.roles_required) { if (!has_role(interaction, role_id)) throw new BotError("Missing one of the required roles to buy this item"); diff --git a/commands/create_item.ts b/commands/create_item.ts index 59138c0..808ad4c 100644 --- a/commands/create_item.ts +++ b/commands/create_item.ts @@ -17,7 +17,7 @@ async function run(interaction: ChatInputCommandInteraction) { if (name.includes("`") || name.includes(",") || name.includes("|")) throw new BotError("Item name cannot include the following characters:`|,"); //don't want to escape shit //to add multiple roles, people will have to use /edit_item, I guess? augh const required_role = (await options.get("required_role"))?.role; - if (price <= 0) throw new BotError("Price cannot be zero or negative"); //undefined < 0 is false btw + if (price < 0) throw new BotError("Price cannot be negative"); //undefined < 0 is false btw //name and description char limits (based on discord embed field name/value limits) if (name.length > 200) throw new BotError("Item name cannot be more than 256 characters"); //true limit is 256 (still might error if currency name is more than like 50 characters, or price is absurdly huge) if (description.length > 900) throw new BotError("Item description cannot be more than 1024 characters"); //true limit is 1024 but we want some margin for other info diff --git a/commands/edit_item.ts b/commands/edit_item.ts index f72fcfa..ae6a761 100644 --- a/commands/edit_item.ts +++ b/commands/edit_item.ts @@ -18,7 +18,7 @@ async function run(interaction: ChatInputCommandInteraction) { const usable: boolean = ((await options.get("usable"))?.value ?? item.usable) as boolean; //to add multiple roles, people will have to use /edit_item, I guess? augh const required_role = (await options.get("required_role"))?.role; - if (price <= 0) throw new BotError("Price cannot be zero or negative"); + if (price < 0) throw new BotError("Price cannot be negative"); //name and description char limits (based on discord embed field name/value limits) if (description.length > 900) throw new BotError("Item description cannot be more than 1024 characters"); //true limit is 1024 but we want some margin for other info const existing = delete_existing_roles ? [] : item.roles_required; diff --git a/commands/store.ts b/commands/store.ts index e8258fa..d6e48a8 100644 --- a/commands/store.ts +++ b/commands/store.ts @@ -22,7 +22,7 @@ async function run(interaction: ChatInputCommandInteraction) { .map( (store_item: StoreItem) => ({ - name: `${store_item.name} (${ !store_item.price ? "unbuyable" : `${store_item.price} ${ store_item.price === 1 ? config.currency : config.currency_plural }` })`, + name: `${store_item.name} (${ store_item.price === null ? "unbuyable" : `${store_item.price} ${ store_item.price === 1 ? config.currency : config.currency_plural }` })`, value: `${store_item.description}\nUsable: ${store_item.usable}${ store_item.roles_required.length === 0 ? "" : `\nRoles required: ${store_item.roles_required.map((role_id) => `<@&${role_id}>`).join("")}` }${ store_item.items ? "\nItems used: " + store_item.items.map((item) => `${item[1]} of \`${item[0]}\``).join(" + ") : "" }`, }) )