#Validation Error - Expected a string primitive

4 messages · Page 1 of 1 (latest)

graceful escarp
#

Hi.

When I add this piece of code to my SlashCommandBuilder

  .addIntegerOption(option =>
    option
      .setMinValue(0)
      .setMaxValue(challengesData.length - 1)
      .setRequired(false))

I get this error

ValidationError: Expected a string primitive
    at StringValidator.handle (D:\Projekti\discord-bots\challenger\bot\node_modules\@sapphire\shapeshift\dist\index.js:1654:70)
    at StringValidator.parse (D:\Projekti\discord-bots\challenger\bot\node_modules\@sapphire\shapeshift\dist\index.js:113:88)
    at validateName (D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\Assertions.cjs:11:17)
    at Object.validateRequiredParameters (D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\Assertions.cjs:26:3)
    at MixedClass.runRequiredValidations (D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\mixins\ApplicationCommandOptionBase.cjs:19:16)
    at MixedClass.toJSON (D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\options\integer.cjs:40:10)
    at D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\SlashCommandBuilder.cjs:37:52
    at Array.map (<anonymous>)
    at MixedClass.toJSON (D:\Projekti\discord-bots\challenger\bot\node_modules\@discordjs\builders\dist\interactions\slashCommands\SlashCommandBuilder.cjs:37:29)
    at Object.<anonymous> (D:\Projekti\discord-bots\challenger\bot\deploy-commands.js:11:29) {
  validator: 's.string',
  given: undefined
}

I can't figure out why is the error happening. Could anyone assist me on this?

#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

blissful flint
#

you didn't set the name/desc of the option

graceful escarp
#

Oh, that's right