// create select menu
const select = new ActionRowBuilder<SelectMenuBuilder>().addComponents(
new SelectMenuBuilder()
.setCustomId(Date.now.toString())
.setPlaceholder("Claim a role")
.addOptions(...);
...
// create component selector
const collector = this.message.createMessageComponentCollector({ componentType: ComponentType.StringSelect });
collector.on("collect", async (interaction: SelectMenuInteraction) => {
// validate option
if (!isValid(interaction.values[0], interaction.user.id)) {
const waitListButton = new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId(`${message.id}-${user.id}`)
.setLabel("Join waitlist")
.setStyle(ButtonStyle.Success)
);
const waitlistMessage = await interaction.reply({ content: "join waitlist...", ephemeral: true, components: [waitListButton] });
const waitlistCollector = waitlistMessage.createMessageComponentCollector({
componentType: ComponentType.Button,
time: 30_000,
});
waitlistCollector.on("collect", async (interaction: ButtonInteraction) => {
console.log(`<@${interaction.user.id}> joined the waitlist`);
await interaction.reply({ content: "Thank you for joining the waitlist", ephemeral: true });
});
return;
}
// handle valid selection
...
await interaction.deferUpdate();
});