• Deploys application commands to a specific guild.

    This function authenticates with the Discord API using the provided token, then deploys the specified commands to the given guild.

    Parameters

    • token: string

      The token used for authentication with the Discord API.

    • discordClientId: string

      The Discord client ID.

    • guildId: string

      The ID of the guild where commands are being deployed.

    • commands: Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">[]

      An array of SlashCommandBuilder representing the commands to be deployed.

    Returns Promise<void>

    A promise that resolves when commands are successfully deployed.

    Throws

    Will throw an error if there is a problem with the deployment.

    Example

    import { commands } from "./commands";
    import { deployCommands } from "@skeet-framework/discord-utils";
    import { DISCORD_APPLICATION_ID, DISCORD_GUILD_ID } from "../config";

    const commandsData = Object.values(commands).map((command) => command.data);

    const run = async () => {
    const token = process.argv[2] || '';
    try {
    await deployCommands(token, DISCORD_APPLICATION_ID, DISCORD_GUILD_ID, commandsData);
    console.log('Commands deployed successfully.');
    } catch (error) {
    console.error(`Error deploying commands: ${error}`);
    }
    };

    run()
    .then(() => console.log('Done'))
    .catch((error) => console.error(error));

Generated using TypeDoc