Dev03
Dev03

Reputation: 3

Discord.JS Invalid Form Body when creating a select menu

I'm new to menu selectors and I'm not really sure why I'm having problems getting started with it.

I've tried to make a test menu selector to get started.

    const menu = new StringSelectMenuBuilder()
        .setCustomId('test')
        .setPlaceholder('Click to select pronouns...')
        .setMinValues(0)
        .setMaxValues(5)
        .addOptions(
            {
                "label": "Test 1",
                "value": "test1"
            },
            {
                "label": "Test 2",
                "value": "test2"
            },
        )
    message.channel.send({components: [new ActionRowBuilder().addComponents(menu)]})

Here's what I've gotten back

DiscordAPIError[50035]: Invalid Form Body
components[0].components[0].options[2].emoji.name[BUTTON_COMPONENT_INVALID_EMOJI]: Invalid emoji
components[0].components[0].options[3].emoji.name[BUTTON_COMPONENT_INVALID_EMOJI]: Invalid emoji
components[0].components[0].options[4].emoji.name[BUTTON_COMPONENT_INVALID_EMOJI]: Invalid emoji
    at handleErrors (DIR\node_modules\@discordjs\rest\dist\index.js:730:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (DIR\node_modules\@discordjs\rest\dist\index.js:1133:23)    
    at async SequentialHandler.queueRequest (DIR\node_modules\@discordjs\rest\dist\index.js:963:14)   
    at async _REST.request (DIR\node_modules\@discordjs\rest\dist\index.js:1278:22)
    at async TextChannel.send (DIR\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:177:15) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      enforce_nonce: false,
      embeds: undefined,
      components: [ { type: 1, components: [ [Object] ] } ],
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined,
      applied_tags: undefined,
      poll: undefined
    }
  },
  rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: {
      components: { '0': { components: { '0': [Object] } } }
    }
  },
  code: 50035,
  status: 400,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/CHANNELID/messages'
}

The "invalid emojis" doesn't really make sense since I didn't use any in the setOptions.

Upvotes: 0

Views: 92

Answers (1)

Fuxlor
Fuxlor

Reputation: 41

i think it's because you set the max value with a number higher than the possible values. .setMaxValues(5) but you have 2 choices you should put .setMaxValues(2) or add more choices.

Upvotes: 0

Related Questions