Hi all, currently creating a command with choices.
Here's the code I wrote, but for some reason, this weird error pops up when applying ...choices to #addChoices
interface ShopItem {
name: string;
type: "aircraft" | "hangar";
size?: string;
price: number;
}
const combinedShop: ShopItem[] = [];
for (const hangar of hangarShop) {
combinedShop.push({
name: hangar.name,
type: "hangar",
size: hangar.type,
price: hangar.price,
});
}
for (const aircraft of aircraftShop) {
combinedShop.push({
name: aircraft.name,
type: "aircraft",
price: aircraft.price,
});
}
const choices = combinedShop.map((item) => ({
name: item.name,
value: item.name,
}));
.addSubcommand((command) =>
command
.setName("buy")
.setDescription("Buy an item from the shop")
.addStringOption((option) =>
option
.setName("item")
.setDescription("An item to purchase")
.setRequired(true)
.addChoices(...choices)
)
)
[ERROR] Encountered error while handling the command application command registry for command "shop" at path "D:\Development\@airbridge\bot\src\commands\shop.ts" ExpectedConstraintError > s.number.lessThanOrEqual
Invalid number value
Expected: expected <= 25
Received:
| 34
