Help with select menus

hey all, im trying to get a select menu collector working but i cant seem to figure it out... i have two rows, each with one multi select menu in it I am making my collector via
const initialMessage = await interaction.editReply({ embeds: [embed], components: components });

const collector = initialMessage.createMessageComponentCollector({
componentType: ComponentType.StringSelect, time: 10000
});
const initialMessage = await interaction.editReply({ embeds: [embed], components: components });

const collector = initialMessage.createMessageComponentCollector({
componentType: ComponentType.StringSelect, time: 10000
});
which works as expected. I collect when there are changes by:
collector.on('collect', async i => {
const changedValues = i.values

// update db with new elements
// db update is here, ommitted for support readability

await i.update({ content: "" }) // this is so discord doesnt say interaction failed
});
collector.on('collect', async i => {
const changedValues = i.values

// update db with new elements
// db update is here, ommitted for support readability

await i.update({ content: "" }) // this is so discord doesnt say interaction failed
});
the problem is back in discord, the select goes back to what it was before I interacted with it anytime i change it. the code works, the db updates properly my adding and removing the values from an array, but discord does not change correctly any idea why this doesnt work as expected?
2 Replies
d.js toolkit
d.js toolkit3mo 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! - Marked as resolved by OP
k4deng
k4deng3mo ago
also it works as expected if i do await i.reply({ content: "test" }) but I dont want to tell the user something changed, i just want it to work without sending a new message every time they change something solved my own problem... my components are defined earlier,
let components = [{
type: ComponentType.ActionRow,
components: [{
type: ComponentType.StringSelect,
customId: `infoSelect-${interaction.user.id}-${interaction.channel.id}`,
placeholder: "Select info elements",
minValues: 0,
maxValues: elementEnums.info.length,
options: elementEnums.info.map(e => ({
label: e,
value: e,
default: sentElements.includes(e)
}))
}]
}, {
type: ComponentType.ActionRow,
components: [{
type: ComponentType.StringSelect,
customId: `dataSelect-${interaction.user.id}-${interaction.channel.id}`,
placeholder: "Select data elements",
minValues: 0,
maxValues: elementEnums.data.length,
options: elementEnums.data.map(e => ({
label: e,
value: e,
default: sentElements.includes(e)
}))
}]
}]
let components = [{
type: ComponentType.ActionRow,
components: [{
type: ComponentType.StringSelect,
customId: `infoSelect-${interaction.user.id}-${interaction.channel.id}`,
placeholder: "Select info elements",
minValues: 0,
maxValues: elementEnums.info.length,
options: elementEnums.info.map(e => ({
label: e,
value: e,
default: sentElements.includes(e)
}))
}]
}, {
type: ComponentType.ActionRow,
components: [{
type: ComponentType.StringSelect,
customId: `dataSelect-${interaction.user.id}-${interaction.channel.id}`,
placeholder: "Select data elements",
minValues: 0,
maxValues: elementEnums.data.length,
options: elementEnums.data.map(e => ({
label: e,
value: e,
default: sentElements.includes(e)
}))
}]
}]
i just update with updated component
components[0].components[0].options = elementEnums.info.map(e => ({
label: e,
value: e,
default: changedValues.includes(e)
}))
components[1].components[0].options = elementEnums.data.map(e => ({
label: e,
value: e,
default: changedValues.includes(e)
}))

// send updated components
await i.update({ components: components })
components[0].components[0].options = elementEnums.info.map(e => ({
label: e,
value: e,
default: changedValues.includes(e)
}))
components[1].components[0].options = elementEnums.data.map(e => ({
label: e,
value: e,
default: changedValues.includes(e)
}))

// send updated components
await i.update({ components: components })