Modals

const modal = new ModalBuilder({
customId: 'customDurationModal',
title: 'Custom Duration',
});

const customDurationInput: TextInputBuilder = new TextInputBuilder()
.setCustomId('duration')
.setPlaceholder('1')
.setMinLength(1)
.setMaxLength(4)
.setRequired(true);

const actionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(customDurationInput);

console.log(actionRow);

console.log(customDurationInput);

modal.addComponents(actionRow);

console.log(interaction);

console.log('custom');

console.log(modal);
await interaction.showModal(modal);
const modal = new ModalBuilder({
customId: 'customDurationModal',
title: 'Custom Duration',
});

const customDurationInput: TextInputBuilder = new TextInputBuilder()
.setCustomId('duration')
.setPlaceholder('1')
.setMinLength(1)
.setMaxLength(4)
.setRequired(true);

const actionRow = new ActionRowBuilder<TextInputBuilder>().addComponents(customDurationInput);

console.log(actionRow);

console.log(customDurationInput);

modal.addComponents(actionRow);

console.log(interaction);

console.log('custom');

console.log(modal);
await interaction.showModal(modal);
Trying to add a modal but I get the below error, any ideas?
[Event: interactionCreate] [Command Error] ValidationError > s.nativeEnum(T)
Expected the value to be a string or number

Received:
| undefined
[18:19]
The error is happening when I try to call await interaction.showModal(modal)
[Event: interactionCreate] [Command Error] ValidationError > s.nativeEnum(T)
Expected the value to be a string or number

Received:
| undefined
[18:19]
The error is happening when I try to call await interaction.showModal(modal)
5 Replies
d.js toolkit
d.js toolkit14mo 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
BenW
BenWOP14mo ago
[Event: interactionCreate] [Command Error] ValidationError > s.nativeEnum(T)
Expected the value to be a string or number

Received:
| undefined

at NativeEnumValidator.handle (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:30:3)
at NativeEnumValidator.parse (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@sapphire\shapeshift\src\validators\BaseValidator.ts:103:2)
at validateRequiredParameters (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\textInput\Assertions.ts:25:26)
at TextInputBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\textInput\TextInput.ts:135:3)
at D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:132:61
at Array.map (<anonymous>)
at ActionRowBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:132:32)
at D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:61
at Array.map (<anonymous>)
at ModalBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:32)
[Event: interactionCreate] [Command Error] ValidationError > s.nativeEnum(T)
Expected the value to be a string or number

Received:
| undefined

at NativeEnumValidator.handle (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@sapphire\shapeshift\src\validators\NativeEnumValidator.ts:30:3)
at NativeEnumValidator.parse (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@sapphire\shapeshift\src\validators\BaseValidator.ts:103:2)
at validateRequiredParameters (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\textInput\Assertions.ts:25:26)
at TextInputBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\textInput\TextInput.ts:135:3)
at D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:132:61
at Array.map (<anonymous>)
at ActionRowBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\components\ActionRow.ts:132:32)
at D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:61
at Array.map (<anonymous>)
at ModalBuilder.toJSON (D:\Repos\001 New Bot\fbw-moderation-bot\node_modules\@discordjs\builders\src\interactions\modals\Modal.ts:98:32)
treble/luna
treble/luna14mo ago
you have to provided a style
d.js docs
d.js docs14mo ago
dtypes v10: TextInputStyle read more
BenW
BenWOP14mo ago
Ahhh legend Thank you
Want results from more Discord servers?
Add your server