k4deng
k4deng
DIAdiscord.js - Imagine an app
Created by k4deng on 3/20/2024 in #djs-questions
Help with select menus
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 })
4 replies
DIAdiscord.js - Imagine an app
Created by k4deng on 3/20/2024 in #djs-questions
Help with select menus
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
4 replies