#modal error

1 messages ยท Page 1 of 1 (latest)

finite thorn
#

im gonna send you the code now

#
const modal = new Modal()
            .setCustomId('ertest')
            .setTitle('test')
            .addComponents(
              new MessageActionRow<ModalActionRowComponent>().addComponents(
                new TextInputComponent()
                  .setCustomId('test')
                  .setLabel('say something')
                  .setStyle('SHORT')
              )
            );

          await bItr.showModal(modal);

          const modalSubmit = await itr.awaitModalSubmit({
            time: 60000,
            filter: (i: ModalSubmitInteraction) =>
              i.user.id.toString() == itr.user.id && i.customId == 'ertest',
          }); // TODO

          console.log(modalSubmit.fields.getTextInputValue('test'));
grand basin
#

care to share the whole code instead of just the small section?

finite thorn
#

bItr is just a button interaction

#

Yes just a sec

grand basin
#

your error believes that you're replying more than just the modal showing

finite thorn
#
let user = await getUser(itr.user.id);
    if (user == null) return;

    let warehouses = Object.keys(user.buildings.warehouse)
      .map((v) => buildings.find((v2) => v2.id == v))
      .filter((v) => v != undefined) as Building[];

    let usersWarehouses = user?.buildings.warehouse;

    let combinedStorages = {};
    for (let i of Object.values(usersWarehouses))
      combinedStorages = { ...combinedStorages, ...i.itemsStored };

    let embed = new DynamicEmbed()
      .setTitle('My Warehouses')
      .setDescription(
        warehouses.reduce(
          (r, i) =>
            r +
            `${i.emoji} ${i.name} \`๐Ÿ”ผ Lv. ${
              usersWarehouses[i.id].level
            }\` \`๐Ÿ“ฆ ${
              Object.keys(usersWarehouses[i.id].itemsStored).length
            }/TODO\` \`๐Ÿ“ ${locations.find((v) => v.id == i.zone)?.name}\`\n`,
          ''
        )
      )
      .addField(
        `Storage \`${Object.values(combinedStorages).length}/TODO\``,
        makeStorageString(combinedStorages),
        true
      )
      .getFormattedEmbed(user);

    itr.reply({ embeds: [embed], components: getButtons() });
    const bItr = await buttonHandler(itr, 10000, ...getButtons(true));
    if (typeof bItr[0] != 'boolean' && typeof bItr[1] != 'undefined')
      await buttonPressCallback(bItr[1]);
  },
finite thorn
#

Ohhh wait maybe i know, could it be because i defer the button interaction?

grand basin
#

that would definitely be it