Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM message - selecting from the mutual servers #4

Open
NidheeshaT opened this issue Sep 30, 2023 · 1 comment
Open

DM message - selecting from the mutual servers #4

NidheeshaT opened this issue Sep 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@NidheeshaT
Copy link
Collaborator

NidheeshaT commented Sep 30, 2023

@NidheeshaT NidheeshaT added the enhancement New feature or request label Sep 30, 2023
@NidheeshaT
Copy link
Collaborator Author

NidheeshaT commented Sep 30, 2023

Example of a menu creation

client.on(Events.InteractionCreate, async (interaction) => {
    if (!interaction.isCommand()) return;

    const stringSelect = new StringSelectMenuBuilder()
        .addOptions(
            new StringSelectMenuOptionBuilder()
                .setLabel("test")
                .setValue("test")
                .setDescription("test")
        )
        .setCustomId("test")
        .setPlaceholder("Select an option")
        .setMinValues(1)
        .setMaxValues(1);

    const row1 = new ActionRowBuilder().addComponents(stringSelect);

    const response = await interaction.reply({
        content: "Select oen from below",
        components: [row1],
        ephemeral: true,
    });
    const collector = response.createMessageComponentCollector({
        componentType: ComponentType.StringSelect,
        max: 1,
        time: 60000,
    });

    collector.on("collect", async (i) => {
        response.edit({ components: [] });
        i.reply({ content: `You selected ${i.values[0]}`, ephemeral: true });
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant