Search code examples
javascriptdiscorddiscord.js

Can you technically add 'Button' in 'Modal' as 'Discord.js'?


Reference this code : https://discordjs.guide/interactions/modals.html#building-and-responding-with-modals

try todo :

    const modal = new Modal()
      .setCustomId('Vote')
      .setTitle('Vote TItle');

    const favoriteColorInput = new TextInputComponent()
      .setCustomId('favoriteColorInput')
      .setLabel("Vote Title")
      .setStyle('SHORT');

    const hobbiesInput = new TextInputComponent()
      .setCustomId('hobbiesInput')
      .setLabel("Value")
      .setStyle('SHORT');

    const addButton = new MessageButton()
      .setCustomId('addButton')
      .setLabel('ADD')
      .setStyle('SUCCESS');

    const firstActionRow = new MessageActionRow().addComponents(favoriteColorInput);
    const secondActionRow = new MessageActionRow().addComponents(hobbiesInput);
    const addButtonActionRow = new MessageActionRow().addComponents(addButton);

    modal.addComponents(firstActionRow, secondActionRow, addButtonActionRow);
    await interaction.showModal(modal);

prediction:

enter image description here


Solution

  • In modals for now, you have only two buttons submit and cancel that are built-in the modal, so you cannot add more buttons to it.