test

Constatic

Discord Bot BaseResponders

Select menu

How to reply discord select menus

Reply to a select menu by setting the Responder type to Select.

command.ts
// ...
const row = createRow(
    new StringSelectMenuBuilder({
        customId: "select/fruits",
        placeholder: "Select fruits",
        options: [
            { emoji: "🍎", label: "Apple", value: "apple" },
            { emoji: "🍉", label: "Melon", value: "melon" },
            { emoji: "🍊", label: "Orange", value: "orange" }
        ]
    })
);
interaction.reply({ ephemeral, components: [row] });
// ...
responder.ts
new Responder({
    customId: "select/fruits",
    type: ResponderType.StringSelect, cache: "cached",
    async run(interaction) {
        const selected = interaction.values[0];
        interaction.update({ ephemeral, content: `${selected} selected`, components: [] });
    },
});

On this page

No Headings