Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Discord.js "ValidationError: Expected a string primitive" when loading commands

$
0
0

I created another command like usual, but it shows the "ValidationError: Expected a string primitive" error and I'm not sure why.This is the at file:///home/egganto/Documents/Athena/src/commands/perimeter.js:157:33 it's referring to:

import { SlashCommandBuilder } from "discord.js";const perimeterCommand = new SlashCommandBuilder()  .setName("perimeter")  .setDescription("Solves for the perimeter")  // subcommand for parallelogram  .addSubcommand((subcommand) =>    subcommand    .setName("parallelogram")    .setDescription("Solves for the perimeter of the parallelogram")    .addNumberOption((option) =>      option      .setName("base")      .setDescription("The value of the base of the parallelogram")      .setRequired(true)    )    .addNumberOption((option) =>      option        .setName("height")        .setDescription("The value of height of the parallelogram")        .setRequired(true)      )    )  // subcommand for triangle  .addSubcommand((subcommand) =>    subcommand)    .setName("triangle")    .setDescription("Finds the perimeter of a triangle")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("value of side a of the triangle")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("b")      .setDescription("value of side b of the triangle")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("c")      .setDescription("value of side c of the triangle")      .setRequired(true)    )  // subcommand for rectangle  .addSubcommand((subcommand) =>    subcommand    .setName("rectangle")    .setDescription("finds the perimeter of a rectangle")    .addNumberOption((option) =>      option      .setName("length")      .setDescription("value of length of rectangle")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("width")      .setDescription("value of length of rectangle")      .setRequired(true)    )  )  // subcommand for square  .addSubcommand((subcommand) =>    subcommand    .setName("square")    .setDescription("fnds perimeter of a square")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("value of a side of a square")      .setRequired(true)    )  )  // subcommand for trapezoid  .addSubcommand((subcommand) =>    subcommand    .setName("trapezoid")    .setDescription("finds perimeter of trapezoid")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("value of side a of trapezoid")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("b")      .setDescription("value of side b of trapezoid")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("c")      .setDescription("value of side c of trapezoid")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("d")      .setDescription("value of side d of trapezoid")      .setRequired(true)    )  )  // subcommand for kite  .addSubcommand((subcommand) =>    subcommand    .setName("kite")    .setDescription("finds perimeter of kite")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("length of first pair of equal sides")      .setRequired(true)    )    .addNumberOption((option) =>      option      .setName("b")      .setDescription("length of second pair of equal sides")      .setRequired(true)    )  )  // subcommand for rhombus  .addSubcommand((subcommand) =>    subcommand    .setName("rhombus")    .setDescription("finds perimeter of rhombus")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("length of a side")      .setRequired(true)    )  )  // subcommand for hexagon  .addSubcommand((subcommand) =>    subcommand    .setName("hexagon")    .setDescription("finds perimeter of hexagon")    .addNumberOption((option) =>      option      .setName("a")      .setDescription("length of a side")      .setRequired(true)    )  );export default perimeterCommand.toJSON();

line 157:33 being export default perimeterCommand.toJSON();

This is the full error:

[nodemon] starting `node ./src/index.js run`/home/egganto/Documents/Athena/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2473    return typeof value === "string" ? Result.ok(value) : Result.err(new ValidationError("s.string", "Expected a string primitive", value));                                                                     ^ValidationError: Expected a string primitive    at _StringValidator.handle (/home/egganto/Documents/Athena/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:2473:70)    at _StringValidator.parse (/home/egganto/Documents/Athena/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:939:90)    at validateName (/home/egganto/Documents/Athena/node_modules/@discordjs/builders/dist/index.js:1578:17)    at validateRequiredParameters (/home/egganto/Documents/Athena/node_modules/@discordjs/builders/dist/index.js:1597:3)    at MixedClass.toJSON (/home/egganto/Documents/Athena/node_modules/@discordjs/builders/dist/index.js:2358:5)    at /home/egganto/Documents/Athena/node_modules/@discordjs/builders/dist/index.js:2506:52    at Array.map (<anonymous>)    at MixedClass.toJSON (/home/egganto/Documents/Athena/node_modules/@discordjs/builders/dist/index.js:2506:29)    at file:///home/egganto/Documents/Athena/src/commands/perimeter.js:157:33    at ModuleJob.run (node:internal/modules/esm/module_job:222:25) {  validator: 's.string',  given: undefined}Node.js v20.12.2

I tried checking if I missed any description/require attributes, and if I haven't missed anything, I think it might not be missing something


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>