UNPKG

@dookdiks/discord-bot-builder

Version:
33 lines (32 loc) 1.28 kB
import { ClientOptions, GatewayIntentBits } from "discord.js"; import { BaseEventHandler } from "./events"; export interface BotBuilderOptions extends Omit<ClientOptions, "intents"> { token: string; clientId: string; guildId?: string; intents?: (keyof typeof GatewayIntentBits)[]; } export declare class BotBuilder { private readonly token; private readonly clientId; private readonly guildId?; private readonly rest; private readonly client; private readonly slashCommands; constructor({ token, clientId, guildId, intents, ...clientOptions }: BotBuilderOptions); /** Utility to convert string intent keys to actual bitfield values */ private static resolveIntents; /** Dynamically determine correct API route for slash commands */ private getCommandsRoute; /** Register all slash commands via Discord REST API */ private registerSlashCommands; /** Clear all slash commands (useful for cleanup/testing) */ deleteSlashCommands(): Promise<void>; /** Start the Discord bot and register commands on ready */ login(): Promise<string>; /** * Attach an event handler. * If it's a slash command handler, queue its command for registration. */ use(handler: BaseEventHandler): this; }