#Select menu displaying the placeholder on update

33 messages · Page 1 of 1 (latest)

sturdy nest
#

The original content of the message is updated when a value on the select menu is picked, but the select menu itself is also reset so that it says "Select a category" everytime something is picked, rather than showing the selected option.

#
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

spiral rock
spiral rock
# sturdy nest 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)
sturdy nest
spiral rock
#

edited

sturdy nest
#

doesn't work

#

is i.value supposed to be i.values[0]

spring zinc
sturdy nest
#

referring to o.values[0]

spring zinc
#

that component isn't select menu

sturdy nest
#

?

#

what do you mean

spring zinc
#

selectmenu.components[0] isn't a select menu

#

it can be for example button

#

no

#

wait

spring zinc
#

my bad

sturdy nest
#

so

#

what should it be?

spiral rock
#

o.value

sturdy nest
#

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],
          });
        }
      });```
spiral rock
sturdy nest
#

ah ok

#

that works

#

thank you