Discord.JS 创建选择菜单时表单主体无效

问题描述 投票:0回答:1

我是菜单选择器的新手,我不太确定为什么我在开始使用它时遇到问题。

我尝试制作一个测试菜单选择器来开始。

    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)]})

这是我回来的

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'
}

“无效表情符号”并没有真正意义,因为我没有在 setOptions 中使用任何表情符号。

node.js discord discord.js interaction
1个回答
0
投票

我认为这是因为您设置的最大值的数字高于可能的值。

.setMaxValues(5)
但是你有2个选择 您应该添加
.setMaxValues(2)
或添加更多选择。

© www.soinside.com 2019 - 2024. All rights reserved.