最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Discord Modal with SelectMenu - Stack Overflow

programmeradmin0浏览0评论

I'm trying to add a select menu inside a modal (I pretty sure it's possible) but I ended up in this situation and getting this error in the console:

const modal = new client.discord.ModalBuilder()
        .setCustomId('verification-modal')
        .setTitle('Verify yourself')
        .addComponents([
          new client.discord.ActionRowBuilder().addComponents(
            new client.discord.SelectMenuBuilder()
            .setCustomId('t')
            .setPlaceholder('Nothing selected')
                      .addOptions(
                          {
                              label: 'Select me',
                              description: 'This is a description',
                              value: 'first_option',
                          },
                          {
                              label: 'You can select me too',
                              description: 'This is also a description',
                              value: 'second_option',
                          },
                      ),

            new client.discord.TextInputBuilder()
              .setCustomId('verification-input')
              .setLabel('Answer')
              .setStyle(client.discord.TextInputStyle.Short)
              .setMinLength(4)
              .setMaxLength(12)
              .setPlaceholder('ABCDEF')
              .setRequired(true),
          ),
        ]);

      await interaction.showModal(modal);
ode:events:490
      throw er; // Unhandled 'error' event
      ^

DiscordAPIError[50035]: Invalid Form Body
dataponents[0]ponents[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (4,).

if you have any solution '^^

I'm trying to add a select menu inside a modal (I pretty sure it's possible) but I ended up in this situation and getting this error in the console:

const modal = new client.discord.ModalBuilder()
        .setCustomId('verification-modal')
        .setTitle('Verify yourself')
        .addComponents([
          new client.discord.ActionRowBuilder().addComponents(
            new client.discord.SelectMenuBuilder()
            .setCustomId('t')
            .setPlaceholder('Nothing selected')
                      .addOptions(
                          {
                              label: 'Select me',
                              description: 'This is a description',
                              value: 'first_option',
                          },
                          {
                              label: 'You can select me too',
                              description: 'This is also a description',
                              value: 'second_option',
                          },
                      ),

            new client.discord.TextInputBuilder()
              .setCustomId('verification-input')
              .setLabel('Answer')
              .setStyle(client.discord.TextInputStyle.Short)
              .setMinLength(4)
              .setMaxLength(12)
              .setPlaceholder('ABCDEF')
              .setRequired(true),
          ),
        ]);

      await interaction.showModal(modal);
ode:events:490
      throw er; // Unhandled 'error' event
      ^

DiscordAPIError[50035]: Invalid Form Body
data.ponents[0].ponents[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (4,).

if you have any solution '^^

Share Improve this question asked Feb 7, 2023 at 23:48 JohannCJohannC 611 gold badge1 silver badge6 bronze badges 1
  • 1 No, it's not possible. – MrMythical Commented Feb 8, 2023 at 0:29
Add a ment  | 

1 Answer 1

Reset to default 7

Only text inputs are supported on modals.

Documentation Reference

发布评论

评论列表(0)

  1. 暂无评论