UPDATE: I have made adjustments to the code based on waki285's recommendation, but unfortunately, the issue persists.
In accordance with the instructions provided in the discord.js guide on component interactions, I have been attempting to enable my select menu by utilizing an .awaitMessageComponent()
function on the interaction reply. Below is the code snippet:
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("roleselect")
.setPlaceholder("Select your role!")
.addOptions(
{ label: "role1", value: "role1" },
{ label: "role2", value: "role2" }
);
const prompt = await this.interaction.reply({
content: "Please select your role!",
ephemeral: true,
components: [
new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
selectMenu
),
],
});
const menuInteraction = await prompt.awaitMessageComponent({
filter: (interaction) =>
interaction.user.id === this.interaction.user.id,
time: 600 * 1000,
componentType: ComponentType.StringSelect,
});
const selectedRoleValue = menuInteraction.values[0];
The visual representation of the select menu appears properly:
https://i.sstatic.net/pSsDp.png
However, upon selecting an option, the interaction fails and the bot never reaches the line where selectedRoleValue
is assigned:
https://i.sstatic.net/KazYA.png
Although the interaction is detected by my
client.on("interactionCreate", ...)
segment (where it is logged and disregarded), it fails to be recognized by the prompt.awaitMessageComponent()
portion of the code. I also experimented with using a component collector instead, but encountered similar issues with interaction detection.
Your assistance in resolving this matter would be highly appreciated!