#Select menu displaying the placeholder on update
33 messages · Page 1 of 1 (latest)
const selectmenu = new MessageActionRow().addComponents(
new MessageSelectMenu()
.setCustomId("selectmenu")
.addOptions([
{
label: "Economy",
description: "View all economy commands",
value: "economy",
},
{
label: "Fun",
description: "View all fun commands",
value: "fun",
},
{
label: "Info",
description: "View all info commands",
value: "info",
},
{
label: "Stats",
description: "View all stats commands",
value: "stats",
},
{
label: "Utils",
description: "View all utils commands",
value: "utils",
},
])
);
await interaction.reply({
content: "test",
allowedMentions: { repliedUser: false },
components: [selectmenu],
});
const filter = async(menu) => {
await menu.deferUpdate();
return menu.isSelectMenu() && menu.customId == "selectmenu" && interaction.member.id === menu.member.id;
};
const mCollector = interaction.channel.createMessageComponentCollector({
filter,
idle: 15_000,
componentType: "SELECT_MENU",
});
mCollector.on("collect", (i) => {
console.log(i);
if (
i.values[0] == "economy" ||
i.values[0] == "fun" ||
i.values[0] == "info" ||
i.values[0] == "stats" ||
i.values[0] == "utils"
) {
i.editReply({
content: i.values[0],
});
}
});```is there something i'm overlooking that's causing the select menu value to be reset on selection? The text content of the original message is updated but the select menu value is also reset, which displays the placeholder message.
Select menu displaying the placeholder on update
when you edit the original message the select menu will be reset.
You can aviod this by editing components making the selected value is defualt
how could I do that?
do this then send selectmenu in the editReply
selectmenu.components[0].options.forEach((o) => o.value == i.value ? o.default = true : o.default = false)
says o.setDefault is not a function
edited
can be simplified
selectmenu.components[0].options.forEach((o) => o.default = o.values[0] == i.values[0])
TypeError: Cannot read properties of undefined (reading '0')
referring to o.values[0]
that component isn't select menu
selectmenu.components[0] isn't a select menu
it can be for example button
no
wait
option don't have values
my bad
o.value
doesn't work
same thing, it resets
const selectmenu = new MessageActionRow().addComponents(
new MessageSelectMenu().setCustomId("selectmenu").addOptions([
{
label: "Economy",
description: "View all economy commands",
value: "economy",
},
{
label: "Fun",
description: "View all fun commands",
value: "fun",
},
{
label: "Info",
description: "View all info commands",
value: "info",
},
{
label: "Stats",
description: "View all stats commands",
value: "stats",
},
{
label: "Utils",
description: "View all utils commands",
value: "utils",
},
])
);
await interaction.reply({
content: "test",
allowedMentions: { repliedUser: false },
components: [selectmenu],
});
const filter = async (menu) => {
await menu.deferUpdate();
return (
menu.isSelectMenu() &&
menu.customId == "selectmenu" &&
interaction.member.id === menu.member.id
);
};
const mCollector = interaction.channel.createMessageComponentCollector({
filter,
idle: 15_000,
componentType: "SELECT_MENU",
});
mCollector.on("collect", (i) => {
if (
i.values[0] == "economy" ||
i.values[0] == "fun" ||
i.values[0] == "info" ||
i.values[0] == "stats" ||
i.values[0] == "utils"
) {
selectmenu.components[0].options.forEach(
(o) => (o.default = o.value == i.values[0])
);
i.editReply({
content: i.values[0],
});
}
});```
yeah told you put selectmenu in the editReply