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.