Function handleCommands

  • Handles Discord commands for a Discord.js client.

    Returns

    An object containing the loaded commands and any errors.

    Example

    import { Client, GatewayIntentBits } from "discord.js";
    import { handleCommands } from "discmd-handler";

    const client = new Client({
    intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    ]
    });

    handleCommands({
    client,
    commands: {
    ButtonCommands: "commands/button",
    ChatInputCommands: "commands/chat-input",
    MessageCommands: "commands/message",
    SelectMenuCommands: "commands/select-menu",
    },
    prefix: "!",
    });

    client.login();

    Parameters

    Returns Promise<{
        commands: {
            ButtonCommands: Collection<string, ButtonCommand>;
            ChatInputCommands: Collection<string, ChatInputCommand>;
            MessageCommands: Collection<string, MessageCommand>;
            SelectMenuCommands: Collection<string, SelectMenuCommand>;
        };
        errors: Record<"ButtonCommands" | "ChatInputCommands" | "MessageCommands" | "SelectMenuCommands", unknown[]>;
    }>

Generated using TypeDoc