fix
This commit is contained in:
@@ -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");
|
if (quantity <= 0) throw new BotError("Can't buy 0 or less of an item. Nice try");
|
||||||
const item = await get_item(name);
|
const item = await get_item(name);
|
||||||
if (!item) throw new BotError("Item does not exist");
|
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) {
|
if (item.roles_required.length > 0) {
|
||||||
for (const role_id of item.roles_required) {
|
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");
|
if (!has_role(interaction, role_id)) throw new BotError("Missing one of the required roles to buy this item");
|
||||||
|
|||||||
@@ -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
|
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
|
//to add multiple roles, people will have to use /edit_item, I guess? augh
|
||||||
const required_role = (await options.get("required_role"))?.role;
|
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)
|
//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 (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
|
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
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ async function run(interaction: ChatInputCommandInteraction) {
|
|||||||
const usable: boolean = ((await options.get("usable"))?.value ?? item.usable) as boolean;
|
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
|
//to add multiple roles, people will have to use /edit_item, I guess? augh
|
||||||
const required_role = (await options.get("required_role"))?.role;
|
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)
|
//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
|
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;
|
const existing = delete_existing_roles ? [] : item.roles_required;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ async function run(interaction: ChatInputCommandInteraction) {
|
|||||||
.map(
|
.map(
|
||||||
(store_item: StoreItem) =>
|
(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(" + ") : "" }`,
|
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(" + ") : "" }`,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user