How to use .setChoices/.addChoices. SlashCommandBuilder

context i am making a embed command, i am receiving this error for each of my options
ValidationError: Expected the value to be an object, but received string instead
at _ObjectValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2070:9)
at _ObjectValidator.run (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:958:23)
at _ArrayValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1248:37)
at _ArrayValidator.parse (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at MixedClass.addChoices (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2118:22)
at /Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:10:14
at MixedClass._sharedAddOptionMethod (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2439:50)
at MixedClass.addStringOption (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2411:17)
at Object.<anonymous> (/Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1739:14) {
validator: 's.object(T)',
given: 'Random'
ValidationError: Expected the value to be an object, but received string instead
at _ObjectValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2070:9)
at _ObjectValidator.run (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:958:23)
at _ArrayValidator.handle (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1248:37)
at _ArrayValidator.parse (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:972:90)
at MixedClass.addChoices (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2118:22)
at /Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:10:14
at MixedClass._sharedAddOptionMethod (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2439:50)
at MixedClass.addStringOption (/Users/rileyrager/WebstormProjects/CelestialBot/node_modules/@discordjs/builders/dist/index.js:2411:17)
at Object.<anonymous> (/Users/rileyrager/WebstormProjects/CelestialBot/commands/utility/embed.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1739:14) {
validator: 's.object(T)',
given: 'Random'
note this error is happening with each of my options
3 Replies
d.js toolkit
d.js toolkit2d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
RateLimited
RateLimitedOP2d ago
.addStringOption(option => option
.setName('color')

.addChoices(["Default", "White", "Aqua", "Green", "Blue", "Yellow", "Purple", "LuminousVividPink", "Fuchsia", "Gold", "Orange", "Red", "Grey", "Navy", "DarkAqua", "DarkGreen", "DarkBlue", "DarkPurple", "DarkVividPink", "DarkGold", "DarkOrange", "DarkRed", "DarkGrey", "DarkerGrey", "LightGrey", "DarkNavy", "Blurple", "Greyple", "DarkButNotBlack", "NotQuiteBlack", "Random"])
.setDescription('easy embed color picker refer, for custom use r,g,b options.'),

)
.addStringOption(option => option
.setName('color')

.addChoices(["Default", "White", "Aqua", "Green", "Blue", "Yellow", "Purple", "LuminousVividPink", "Fuchsia", "Gold", "Orange", "Red", "Grey", "Navy", "DarkAqua", "DarkGreen", "DarkBlue", "DarkPurple", "DarkVividPink", "DarkGold", "DarkOrange", "DarkRed", "DarkGrey", "DarkerGrey", "LightGrey", "DarkNavy", "Blurple", "Greyple", "DarkButNotBlack", "NotQuiteBlack", "Random"])
.setDescription('easy embed color picker refer, for custom use r,g,b options.'),

)
d.js docs
d.js docs2d ago
documentation suggestion for @RateLimited: :method: SlashCommandStringOption#addChoices() [email protected] Adds multiple choices to this option.

Did you find this page helpful?