ExpectValidationError expected
I'm getting a weird error message from the sapphire node module.
Here's the message:
C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:41
throw this.error;
^
ExpectedValidationError: Expected
at InstanceValidator.handle (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:714:75)
at InstanceValidator.parse (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:201:88)
at assertReturnOfBuilder (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:942:53)
at MixedClass._sharedAddOptionMethod (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:1347:5)
at MixedClass.addStringOption (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:1335:17)
at Object.<anonymous> (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\command.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
validator: 's.instance(V)',
given: undefined,
expected: [Function: SlashCommandStringOption]
}
C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:41
throw this.error;
^
ExpectedValidationError: Expected
at InstanceValidator.handle (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:714:75)
at InstanceValidator.parse (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@sapphire\shapeshift\dist\index.js:201:88)
at assertReturnOfBuilder (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:942:53)
at MixedClass._sharedAddOptionMethod (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:1347:5)
at MixedClass.addStringOption (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\node_modules\@discordjs\builders\dist\index.js:1335:17)
at Object.<anonymous> (C:\Users\esmit\source\repos\Visual-Studio-Code-Projects\gamebot\command.js:7:10)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
validator: 's.instance(V)',
given: undefined,
expected: [Function: SlashCommandStringOption]
}
9 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Show your code
const { SlashCommandBuilder, EmbedBuilder, channelLink } = require("discord.js")
const stats = require("./stats.json")
module.exports = {
data: new SlashCommandBuilder()
.setName('stats')
.setDescription("Gets you the stats of yourself or another person")
.addStringOption(function(option){
option.setName("person")
.setDescription(`The person to get the stats of.
If this is not provided, this will automatically get your stats.`)
.addChoices(
{name: "removed", value: "removed"},
{name: "removed", value: "removed"}
)
}),
async execute(interaction){
const person = interaction.options.getString('person')
// Get their stats from the JSON file and display them to the user only.
const type = stats[person].Type
const hp = stats[person].HP
const gold = stats[person].Gold
const mp = stats[person].MP
const statsEmbed = new EmbedBuilder()
.setColor(0xff0000)
.setTitle(`${person}'s Stats`)
.addFields(
{name: "Type/Class", value: type},
{name: "HP", value: hp},
{name: "Gold", value: gold},
{name: "MP", value: mp}
)
.setFooter("Made by BestSpark687090")
await interaction.reply({embeds: [statsEmbed], ephemeral: true})
}
}
const { SlashCommandBuilder, EmbedBuilder, channelLink } = require("discord.js")
const stats = require("./stats.json")
module.exports = {
data: new SlashCommandBuilder()
.setName('stats')
.setDescription("Gets you the stats of yourself or another person")
.addStringOption(function(option){
option.setName("person")
.setDescription(`The person to get the stats of.
If this is not provided, this will automatically get your stats.`)
.addChoices(
{name: "removed", value: "removed"},
{name: "removed", value: "removed"}
)
}),
async execute(interaction){
const person = interaction.options.getString('person')
// Get their stats from the JSON file and display them to the user only.
const type = stats[person].Type
const hp = stats[person].HP
const gold = stats[person].Gold
const mp = stats[person].MP
const statsEmbed = new EmbedBuilder()
.setColor(0xff0000)
.setTitle(`${person}'s Stats`)
.addFields(
{name: "Type/Class", value: type},
{name: "HP", value: hp},
{name: "Gold", value: gold},
{name: "MP", value: mp}
)
.setFooter("Made by BestSpark687090")
await interaction.reply({embeds: [statsEmbed], ephemeral: true})
}
}
The function should return the option
So just have
return option
at the end?Add
return option
or use (option) => option
ok
Nope, still same error
Did you save the file?
wait hold on i think i put it in the wrong place
i put it in the execute, not the data
ok its working