Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Latest commit

 

History

History
54 lines (50 loc) · 1.46 KB

selectMenus.md

File metadata and controls

54 lines (50 loc) · 1.46 KB

SelectMenus

Format

// This format is for the button file that you will create in `src/interactions/selectMenus`.
import { SelectMenu } from "../../types.js";

export const Menu: SelectMenu = {
    name: "selectMenuName",
    // Other Command Options
    run: (interaction): void => {
        // Code
    }
}; 

Example Code

SelectMenu Creation Code

import { ActionRowBuilder, StringSelectMenuBuilder } from "discord.js";

message.channel.send({
    content: "Cookies SelectMenu",
    components: [
        new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(
            new StringSelectMenuBuilder()
              .setCustomId("SelectMenuExample")
              .setPlaceholder("Free Cookies!")
              .addOptions(
                [{
                    label: "Click for cookies!",
                    description: "Freeee!",
                    value: "CookieBox"
                }]
            )
        )
    ]
});

SelectMenu Code

// Code for the `src/interactions/selectMenus/selectMenuExample.js
import { SelectMenu } from "../../types.js";

export const Menu: SelectMenu = {
    name: "SelectMenuExample",
    // Other Command Options
    run: (interaction): void => {
        interaction = interaction as StringSelectMenuInteraction<"cached">; // If you want to use StringSelectMenuInteraction specifically.
        
        interaction.reply({
            content: "Here is your cookie! :cookie:"
        });
    }
};