Function registerApplicationCommands

  • Registers slash commands for a Discord bot application.

    Remarks

    This function reads all .js, .cjs and .mjs files in a specified directory and attempts to parse them as chat input commands for Discord slash commands. It then sends the commands to the Discord API using the provided bot token.

    Returns

    An object containing the registered commands and any errors encountered during registration.

    Example

    import { registerApplicationCommands } from "discmd-handler";

    registerApplicationCommands({
    token: process.env.DISCORD_TOKEN,
    commands: {
    ChatInputCommands: "commands/chat-input",
    },
    });

    Parameters

    Returns Promise<{
        commands: RESTPostAPIChatInputApplicationCommandsJSONBody[];
        errors: unknown[];
    }>

Generated using TypeDoc