Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!