Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

311
Vistas
Error in adding role options to Slash Command ~ @discordjs/builders

I am trying to make multiple role options for slash commands. I am using Slash Command builder - @discordjs/builders I have tried different ways but not working. This is my code:

    data: new SlashCommandBuilder()
        .setName('roles')
        .setDescription('Choices')
        .addRoleOption(role =>
          role.setName('role 1').setDescription('Choice 1').setRequired(false)
        )
        .addRoleOption(role =>
          role.setName('role 2').setDescription('Choice 2').setRequired(false)
        )
        .addRoleOption(role =>
          role.setName('role 3').setDescription('Choice 3').setRequired(false)
        )
        .addRoleOption(role =>
          role.setName('role 4').setDescription('Choice 4').setRequired(false)
        )
        .addRoleOption(role =>
          role.setName('role 5').setDescription('Choice 5').setRequired(false)
        ),

The errors I got for making this:

S[50035]: Invalid Form Body
3.options[0].name[STRING_TYPE_REGEX]: String value did not match validation regex.
3.options[1].name[STRING_TYPE_REGEX]: String value did not match validation regex.
3.options[2].name[STRING_TYPE_REGEX]: String value did not match validation regex.
3.options[3].name[STRING_TYPE_REGEX]: String value did not match validation regex.
3.options[4].name[STRING_TYPE_REGEX]: String value did not match validation regex.
    at Q.runRequest (/home/runner/ticket-1/node_modules/@discordjs/rest/dist/index.js:7:581)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Q.queueRequest (/home/runner/ticket-1/node_modules/@discordjs/rest/dist/index.js:5:2942)
    at async /home/runner/ticket-1/handler/slashCommand.js:35:9 {
  rawError: {
    code: 50035,
    errors: { '3': [Object] },
    message: 'Invalid Form Body'
  },
  code: 50035,
  status: 400,
  method: 'put',
  url: 'https://discord.com/api/v9/applications/935368903209672726/guilds/908385923673231481/commands',
  requestBody: {
    files: undefined,
    json: [ [Object], [Object], [Object], [Object] ]
  }
}

Please help me solve this problem.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found out the problem now: You cannot include space between the option name's characters.

Therefore, the code is:

.addRoleOption(role =>
    role.setName('role1').setDescription('Select role').setRequired(false)
)

I hope this will help others if they have same problem.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda