#@sapphire/shapeshift ExpectedConstraintError

1 messages · Page 1 of 1 (latest)

haughty stratus
#

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
thorny stumpBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

normal charm
#

Maximum amount of options is 25

#

You provided 34

haughty stratus
#

oh

#

Oops sorry I didn't read it properly facepalm

thorny stumpBOT
#

Thank you for marking this question as solved!

Question Message ID

1097956594412687360

Solution Message ID

1097960994426339381

normal charm
#

@stuck moss example of very long question very short answer 😉

#

Relating back to our conversation of before