Home > Blockchain >  How is this messageComponentCollector not working? (discord.js v13)
How is this messageComponentCollector not working? (discord.js v13)

Time:01-12

I'm trying to make a message component collector on this message and to only read Select Menu components.

However, the collector seems to exist but it doesn't collect. As when I change something in the Select Menu, the menu says "This interaction failed."

Here's the code:

if (wikiEmbeds.length > 1) {
    let selectMenuOptions = []
    for (let i = 0; i < wikiEmbeds.length; i  ) {
        const selectedContent = wikiEmbeds[i];
        if (i == 0) {
            selectMenuOptions.push(
                {
                    label: selectedContent.tableName,
                    value: `${i}`,
                    default: true
                }
            )
        } else {
            selectMenuOptions.push(
                {
                    label: selectedContent.tableName,
                    value: `${i}`
                }
            )
        }      
    }
    let messageRow = new Discord.MessageActionRow()
    .addComponents(
        new Discord.MessageSelectMenu({
            
        })
        .setCustomId("ds3-bosses-menu")
        .addOptions(selectMenuOptions)
    )
    const initialMessage = await interaction.reply({ embeds: [wikiEmbeds[0].embed], components: [messageRow], fetchReply: true })

    const filter = (i) => {  } 
    const collector = initialMessage.channel.createMessageComponentCollector({
        filter,
        componentType: 'SELECT_MENU',
        time: 30000
    })
    console.log(collector)
    collector.on("collect", (selectInteraction) => {
        selectInteraction.reply(" . ")
    })
}

wikiEmbeds is an array of tables, all of them like this { tableName: string, embed: embed }[]

CodePudding user response:

I am pretty sure it's your filter. Your filter must return true to collect the SelectMenu. Try const filter = (i) => true;

  • Related