blackcat.js-discord - v1.0.10
    Preparing search index...

    Type Alias SelectMenu

    SelectMenu:
        | {
            options: BaseMenu & { options: APISelectMenuOption[] };
            type: "stringmenu";
        }
        | { options: BaseMenu; type: "rolemenu" }
        | { options: BaseMenu; type: "usermenu" }
        | {
            options: BaseMenu & { channelTypes?: ChannelType[] };
            type: "channelmenu";
        }
        | { options: BaseMenu; type: "mentionmenu" }

    Định nghĩa cấu hình cho các loại Select Menu trong ComponentBuilder

    Type Declaration

    • { options: BaseMenu & { options: APISelectMenuOption[] }; type: "stringmenu" }
      • options: BaseMenu & { options: APISelectMenuOption[] }
      • type: "stringmenu"

        String Select Menu (chọn từ danh sách option)

        Đây là loại select menu duy nhất yêu cầu options (danh sách lựa chọn).

    • { options: BaseMenu; type: "rolemenu" }
      • options: BaseMenu
      • type: "rolemenu"

        Role Select Menu (chọn role)

        Cho phép người dùng chọn một hoặc nhiều role trong server.

    • { options: BaseMenu; type: "usermenu" }
      • options: BaseMenu
      • type: "usermenu"

        User Select Menu (chọn user)

        Cho phép chọn user trong server.

    • { options: BaseMenu & { channelTypes?: ChannelType[] }; type: "channelmenu" }
      • options: BaseMenu & { channelTypes?: ChannelType[] }
      • type: "channelmenu"

        Channel Select Menu (chọn channel)

        Có thể filter theo loại channel thông qua channelTypes.

    • { options: BaseMenu; type: "mentionmenu" }
      • options: BaseMenu
      • type: "mentionmenu"

        Mentionable Select Menu (user + role)

        Cho phép chọn cả user và role trong cùng một menu.

    SelectMenu là union type đại diện cho tất cả các loại select menu mà Discord hỗ trợ và builder có thể xử lý.

    Bao gồm:

    • String Select Menu (chọn từ danh sách option)
    • Role Select Menu (chọn role)
    • User Select Menu (chọn user)
    • Channel Select Menu (chọn channel)
    • Mentionable Select Menu (chọn user hoặc role)

    Mỗi cấu hình SelectMenu sẽ được convert thành đúng 1 ActionRowBuilder chứa select menu tương ứng.

    Các thuộc tính chung:

    • customId: định danh duy nhất để xử lý interaction
    • placeholder: text hiển thị khi chưa chọn
    • minValues: số lượng chọn tối thiểu
    • maxValues: số lượng chọn tối đa

    ⚠️ Lưu ý:

    • minValuesmaxValues phải nằm trong range hợp lệ của Discord (0–25)
    • Nếu không set, Discord sẽ dùng default:
      • minValues = 1
      • maxValues = 1
    const menu: SelectMenu = {
    type: "stringmenu",
    options: {
    customId: "menu_1",
    placeholder: "Chọn một giá trị",
    options: [
    { label: "A", value: "a" },
    { label: "B", value: "b" }
    ]
    }
    };
    // Dùng với ComponentBuilder
    const builder = new ComponentBuilder()
    .addSelectMenu({
    type: "usermenu",
    options: {
    customId: "user_select",
    placeholder: "Chọn user"
    }
    });