Type DiscordAPIError [discord.js]

I am trying to make a modal with a dropdown and keep getting an error.

Error:
\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Invalid Form Body
data.components[0]: Value of field "type" must be one of (1,).
    at RequestHandler.execute (E:\Hexagon\hexagon-api\discordbot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RequestHandler.push (E:\Hexagon\hexagon-api\discordbot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async ButtonInteraction.showModal (E:\Hexagon\hexagon-api\discordbot\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:240:5) {
  method: 'post',
  path: '/interactions/997347808371818546/aW50ZXJhY3Rpb246OTk3MzQ3ODA4MzcxODE4NTQ2OlRaSHV4SXp6aTNMVld5OXpGYnU3bDJZRGeGNuMzdCQ1NDdmZUcTJpa1Q2Vndxa09ITU1xdFNEY1dZ/callback',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      type: 9,
      data: {
        components: [
          {
            custom_id: 'application-selector',
            disabled: false,
            placeholder: 'Select the position you want to apply for.',
            min_values: null,
            max_values: undefined,
            options: [Array],
            type: 3
          }
        ],
        custom_id: 'application-modal',
        title: 'Hexagon Career Application'
      }
    },
    files: []
  }
}


My Code:
const discordJS = require('discord.js')
const db = require('../../database')

module.exports = async function(Interaction, client){
    db.query('SELECT * FROM `table`;', async function(err, positions){
        if (positions[0]){
    const modal = new discordJS.Modal()
    modal.setCustomId('application-modal')
    modal.setTitle("Hexagon Career Application")
    let comps = []
    let select = new discordJS.MessageSelectMenu()
    select.setPlaceholder("Select the position you want to apply for.")
    select.setCustomId("application-selector")
    console.log(select.type)
    await positions.forEach(position =>{
        select.addOptions({label: position.positionName,description: position.positionDescription,value: position._id+''})
    })
    comps[0] = select
    modal.setComponents(comps)
console.log('yep')
    Interaction.showModal(modal);

        }else{
            Interaction.editReply({content:":x: Sorry no applications are currently open!"})
        }
    })
}
Was this page helpful?