Unexpected ValidationError when sending modal

After running ConfigSession.send, Discord gets no response and I get the below error (which does not trace back to my program)
C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:50
const casted = value as string | number;
^


ValidationError: Expected the value to be a string or number
at _NativeEnumValidator.handle (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:50:3)
at _NativeEnumValidator.parse (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\BaseValidator.ts:126:2)
at validateRequiredParameters (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\textInput\Assertions.ts:30:26)
at TextInputBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\textInput\TextInput.ts:135:3)
at <anonymous> (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:125:61)
at Array.map (<anonymous>)
at ActionRowBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:125:32)
at <anonymous> (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:61)
at Array.map (<anonymous>)
at ModalBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:32) {
validator: 's.nativeEnum(T)',
given: undefined
}

Node.js v18.20.3
C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:50
const casted = value as string | number;
^


ValidationError: Expected the value to be a string or number
at _NativeEnumValidator.handle (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:50:3)
at _NativeEnumValidator.parse (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@sapphire\shapeshift\src\validators\BaseValidator.ts:126:2)
at validateRequiredParameters (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\textInput\Assertions.ts:30:26)
at TextInputBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\textInput\TextInput.ts:135:3)
at <anonymous> (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:125:61)
at Array.map (<anonymous>)
at ActionRowBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:125:32)
at <anonymous> (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:61)
at Array.map (<anonymous>)
at ModalBuilder.toJSON (C:\Users\jerem\WebstormProjects\magic-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:32) {
validator: 's.nativeEnum(T)',
given: undefined
}

Node.js v18.20.3
16 Replies
d.js toolkit
d.js toolkit5mo 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!
UCYT5040
UCYT5040OP5mo ago
Node v18.20.3, discord.js@14.20.0
d.js docs
d.js docs5mo ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
harnes.xyz
harnes.xyz5mo ago
You should use latest LTS version of NodeJS or atleast version 22.12.0
Node.js 22.12.0 or newer is required.
UCYT5040
UCYT5040OP5mo ago
Got it, updating right now, but I don't think this is related? I'll let you know after I update.
harnes.xyz
harnes.xyz5mo ago
Yeah, but u still should use what is required/recommended
UCYT5040
UCYT5040OP5mo ago
Can confirm I am still having issues (now running v22.17.0)
treble/luna
treble/luna5mo ago
please do this
UCYT5040
UCYT5040OP5mo ago
https://sourceb.in/ycjyxPqAWE Main focus is the send method
treble/luna
treble/luna5mo ago
i can already see one issue there, you're creating nested listeners and where is this.parts defined
d.js docs
d.js docs5mo ago
:method: TextInputBuilder#setStyle() builders@1.11.2 Sets the style for this text input.
UCYT5040
UCYT5040OP5mo ago
could you elaborate?
UCYT5040
UCYT5040OP5mo ago
import {ConfigPart, InputConfigPart, SelectConfigPart} from "../config";

export const starboardConfigParts: ConfigPart[] = [
new SelectConfigPart(
"starboardChannel",
"Channel where messages can be starred",
[], // Options will be channels in the guild, dynamically populated
"channel",
1, // min selections
1, // max selections
["GUILD_TEXT"] // channelTypes
),
new InputConfigPart(
"starboardPostChannel",
"Channel where starred messages are posted",
"e.g. #starboard",
"", // Default value can be empty, user needs to set this
"text" // Assuming this will be a channel name or ID for now, will be resolved to ID later
),
new InputConfigPart(
"starboardReaction",
"Reaction used to star messages",
"e.g. :star: or ⭐",
"⭐",
"text"
),
new InputConfigPart(
"starboardThreshold",
"Stars needed to send a message to starboard",
"#",
10,
"number"
),
new SelectConfigPart(
"starboardMode",
"Starboard mode",
[
{label: "Stars only in configured channel(s)", value: "0"},
{label: "Stars in any channel", value: "1"}
],
"text", // Using text for now, as it represents a choice from predefined options
1,
1
),
new SelectConfigPart(
"starboardAutoReact",
"Automatically react to messages in starred channels",
[
{label: "Yes", value: "true"},
{label: "No", value: "false"}
],
"boolean",
1,
1
)
];
import {ConfigPart, InputConfigPart, SelectConfigPart} from "../config";

export const starboardConfigParts: ConfigPart[] = [
new SelectConfigPart(
"starboardChannel",
"Channel where messages can be starred",
[], // Options will be channels in the guild, dynamically populated
"channel",
1, // min selections
1, // max selections
["GUILD_TEXT"] // channelTypes
),
new InputConfigPart(
"starboardPostChannel",
"Channel where starred messages are posted",
"e.g. #starboard",
"", // Default value can be empty, user needs to set this
"text" // Assuming this will be a channel name or ID for now, will be resolved to ID later
),
new InputConfigPart(
"starboardReaction",
"Reaction used to star messages",
"e.g. :star: or ⭐",
"⭐",
"text"
),
new InputConfigPart(
"starboardThreshold",
"Stars needed to send a message to starboard",
"#",
10,
"number"
),
new SelectConfigPart(
"starboardMode",
"Starboard mode",
[
{label: "Stars only in configured channel(s)", value: "0"},
{label: "Stars in any channel", value: "1"}
],
"text", // Using text for now, as it represents a choice from predefined options
1,
1
),
new SelectConfigPart(
"starboardAutoReact",
"Automatically react to messages in starred channels",
[
{label: "Yes", value: "true"},
{label: "No", value: "false"}
],
"boolean",
1,
1
)
];
No description
UCYT5040
UCYT5040OP5mo ago
^ sample parts Perfect, that fixed the main issue regarding the modal not opening just confused as to what wolvinny is talking about nested listeners i set my listeners on/off yeah but each config session will have its own instance so it should work ok ?
treble/luna
treble/luna5mo ago
you can look into collectors because collectors do that for you
d.js docs
d.js docs5mo ago
:method: ButtonInteraction#awaitModalSubmit() discord.js@14.21.0 Collects a single modal submit interaction that passes the filter. The Promise will reject if the time expires.
// Collect a modal submit interaction
const filter = (interaction) => interaction.customId === 'modal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was submitted!`))
.catch(console.error);
// Collect a modal submit interaction
const filter = (interaction) => interaction.customId === 'modal';
interaction.awaitModalSubmit({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was submitted!`))
.catch(console.error);

Did you find this page helpful?