How to make collector for select menu?

is there something wrong with my code?, it says 'This interaction failed' when i select
const row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Guide')
.addOptions(
{
label: 'Starter',
value: 'starter'
},
{
label: 'Commands',
value: 'commands'
}
)
)

let msg = await interaction.reply({ embeds: [embed], components: [row] })
const collector = msg.createMessageComponentCollector({ componentType: 'SELECT_MENU' })

collector.on('collect', async i => {
const value = i.values[0]
if(!i.user.id == interaction.user.id) return await interaction.reply({ content: 'This selection is not for you!', ephemeral: true })
if(value == 'starter'){
await msg.edit({ embeds: [embed] })
} else if(value == 'commands'){
await msg.edit({ embeds: [commands] })
}
})
const row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId('select')
.setPlaceholder('Guide')
.addOptions(
{
label: 'Starter',
value: 'starter'
},
{
label: 'Commands',
value: 'commands'
}
)
)

let msg = await interaction.reply({ embeds: [embed], components: [row] })
const collector = msg.createMessageComponentCollector({ componentType: 'SELECT_MENU' })

collector.on('collect', async i => {
const value = i.values[0]
if(!i.user.id == interaction.user.id) return await interaction.reply({ content: 'This selection is not for you!', ephemeral: true })
if(value == 'starter'){
await msg.edit({ embeds: [embed] })
} else if(value == 'commands'){
await msg.edit({ embeds: [commands] })
}
})
5 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjalo•2y ago
componentType: ComponentType.StringSelect Import ComponentType from discord.js
markk
markk•2y ago
it worked but i got another error on msg.edit part 😅
await msg.edit({ embeds: [embed] })
^

TypeError: msg.edit is not a function
at InteractionCollector.<anonymous> (C:\Users\Mark\Documents\Programming\Discord Bot\TimeLeap\commands\help.js:48:27)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.handleCollect (C:\Users\Mark\Documents\Programming\Discord Bot\TimeLeap\node_modules\discord.js\src\structures\interfaces\Collector.js:119:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
await msg.edit({ embeds: [embed] })
^

TypeError: msg.edit is not a function
at InteractionCollector.<anonymous> (C:\Users\Mark\Documents\Programming\Discord Bot\TimeLeap\commands\help.js:48:27)
at InteractionCollector.emit (node:events:539:35)
at InteractionCollector.handleCollect (C:\Users\Mark\Documents\Programming\Discord Bot\TimeLeap\node_modules\discord.js\src\structures\interfaces\Collector.js:119:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Syjalo
Syjalo•2y ago
Use i.update() And for "This interaction is not for you" i.reply()
markk
markk•2y ago
thank youu for the help!!