Modal imput question

In current version of discord js can you insert into modal some other components than TextInputBuilder? I cannot see this in discord js docs. I have found some screenshots that it's (was?) possible like in discord modals package. I tried to run this code but it gives error 'DiscordAPIError[50035]: Invalid Form Body data.components[1].components[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (4,). Invalid Form Body' https://www.npmjs.com/package/discord-modals https://user-images.githubusercontent.com/79017590/172033349-816d4b8f-ab1b-4cb4-9d7a-f4919ba9aa70.gif
npm
discord-modals
Discord-Modals is a package that allows your discord.js v13 and v14 bot to create, and interact with Modals, a new Discord feature.. Latest version: 1.3.9, last published: a year ago. Start using discord-modals in your project by running npm i discord-modals. There are 8 other projects in the npm registry using discord-modals.
2 Replies
d.js toolkit
d.js toolkit16mo 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!
SzyMoon
SzyMoonOP16mo ago
And code is here if you want to look up
const modal = new ModalBuilder()
.setCustomId('contact-form')
.setTitle('Dane kontaktowe');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(1);

const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);


const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(select);
modal.addComponents(firstActionRow,secondActionRow);

await interaction.showModal(modal);

})
const modal = new ModalBuilder()
.setCustomId('contact-form')
.setTitle('Dane kontaktowe');

const favoriteColorInput = new TextInputBuilder()
.setCustomId('favoriteColorInput')
// The label is the prompt the user sees for this input
.setLabel("What's your favorite color?")
// Short means only a single line of text
.setStyle(1);

const select = new StringSelectMenuBuilder()
.setCustomId('starter')
.setPlaceholder('Make a selection!')
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel('Bulbasaur')
.setDescription('The dual-type Grass/Poison Seed Pokémon.')
.setValue('bulbasaur'),
new StringSelectMenuOptionBuilder()
.setLabel('Charmander')
.setDescription('The Fire-type Lizard Pokémon.')
.setValue('charmander'),
new StringSelectMenuOptionBuilder()
.setLabel('Squirtle')
.setDescription('The Water-type Tiny Turtle Pokémon.')
.setValue('squirtle'),
);


const firstActionRow = new ActionRowBuilder().addComponents(favoriteColorInput);
const secondActionRow = new ActionRowBuilder().addComponents(select);
modal.addComponents(firstActionRow,secondActionRow);

await interaction.showModal(modal);

})
Thank you for your answer!
Want results from more Discord servers?
Add your server