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

    Interface SlashCommandBuilderOptions<TOptions, TSubs, TGroups>

    Cấu hình khởi tạo cho SlashCommandBuilder.

    Interface này định nghĩa toàn bộ metadata và hành vi của một Slash Command, bao gồm:

    • tên command
    • mô tả
    • quyền sử dụng
    • cooldown
    • options gốc
    • subcommands
    • groups
    • hàm execute
    interface SlashCommandBuilderOptions<
        TOptions extends Record<string, any>
        | undefined = undefined,
        TSubs extends Record<string, ISlashSubCommandBuilder<any>> = {},
        TGroups extends Record<string, ISlashSubCommandGroup<any>> = {},
    > {
        commandName: string;
        cooldown?: CooldownConfig<"interaction">;
        description: string;
        groups?: TGroups;
        options?: (option: OptionFactory) => TOptions;
        subcommands?: TSubs;
        userPermission?: SlashPermissionConfig;
        execute(
            client: Client,
            interaction: ChatInputCommandInteraction,
            options: ExecuteOptions<TOptions, TSubs, TGroups>,
        ): any;
    }

    Type Parameters

    • TOptions extends Record<string, any> | undefined = undefined

      kiểu options gốc của command

    • TSubs extends Record<string, ISlashSubCommandBuilder<any>> = {}

      danh sách subcommand trực tiếp

    • TGroups extends Record<string, ISlashSubCommandGroup<any>> = {}

      danh sách subcommand group

    Index

    Properties

    commandName: string

    Tên slash command.

    Ví dụ:

    /ping
    /moderation
    cooldown?: CooldownConfig<"interaction">

    Cấu hình cooldown cho command.

    Giúp giới hạn tần suất sử dụng command để tránh spam.

    description: string

    Mô tả command hiển thị trong Discord.

    groups?: TGroups

    Danh sách subcommand group.

    Ví dụ:

    /admin user ban
    /admin user kick
    options?: (option: OptionFactory) => TOptions

    Định nghĩa root options cho command.

    Ví dụ:

    options: (option) => ({
    user: option.user({
    description: "User cần xem",
    required: true
    })
    })
    subcommands?: TSubs

    Danh sách subcommand trực tiếp.

    Ví dụ:

    /music play
    /music stop
    userPermission?: SlashPermissionConfig

    Cấu hình quyền người dùng để sử dụng command.

    Nếu người dùng không đủ quyền, message callback sẽ được gọi để trả về phản hồi.

    Methods

    • Hàm thực thi khi slash command được gọi.

      Parameters

      • client: Client

        Discord Client

      • interaction: ChatInputCommandInteraction

        interaction của slash command

      • options: ExecuteOptions<TOptions, TSubs, TGroups>

        object đã được parse và type-safe

        options bao gồm:

        • root options
        • payload subcommand hoặc group

        Ví dụ payload:

        options.payload
        

        có thể là:

        { type: "sub", sub: "ping", options: {} }
        

        hoặc

        {
        type: "group",
        group: "admin",
        sub: "ban",
        options: { user: User }
        }

      Returns any