Search code examples
node.jsdiscorddiscord.js

Discord menu selection interaction failed


I'm trying to create a menu with specific choices but when i try to select one of the choices it says the interaction failed. This is my first time ever using menus on discord and i tried to follow the docs but i cant seem to find what i did wrong.

                const mvpCollector = interaction.channel.createMessageComponentCollector({
                  componentType: 'SELECT_MENU',
                  time: 30000,
                });
                
                mvpCollector.on('collect', async (menuInteraction) => {
                  const mvp = menuInteraction.values[0];
                  
                  if (!team1.has(mvp) && !team2.has(mvp)) {
                    interaction.followUp({content: `${mvp} wasn't in the game!`});
                  } else {
                    mapBanendEmbed.addFields({name: 'MVP', value: `${mvp}`});
                
                    interaction.followUp({
                      embeds: [mapBanendEmbed],
                      components: []
                    });
                  }
                });
                
                mvpCollector.on('end', async (collected) => {
                  if (collected.size === 0) {
                    interaction.followUp({content: 'No MVP was selected.'});
                  }
                });

When a user is selected as the MVP from the select menu it's suppose to edit an embed and set that user as the MVP in the field but it just gives me a interaction failed error.


Solution

  • Component types changed in v14. Use this when creating your collector:

    const { ComponentType } = require('discord.js');
    
    const mvpCollector = interaction.channel.createMessageComponentCollector({
      componentType: ComponentType.SelectMenu, // This line changed
      time: 30000,
    }); 
    

    Also, if you're trying to edit the original message, I think you'll want to use .update() instead of .followUp().