UNPKG

aoijs-command-manager-v2

Version:

A command manager for aoi.js that handles slash commands with ease.

52 lines (51 loc) 1.75 kB
import { SlashCommandBuilder, ApplicationCommandType, ApplicationCommandDataResolvable } from 'discord.js'; import type { AoiClient, AwaitCommand } from 'aoi.js'; export declare class CommandManagerError extends Error { constructor(message: string); } export interface ICommand extends AwaitCommand { data: SlashCommandBuilder | Record<string, any>; type?: ApplicationCommandType; } export interface ApplicationCommandManagerOptions { path?: string; guildIds?: string[]; showTable?: boolean; checkUpdates?: boolean; validateCommands?: boolean; } export declare class ApplicationCommandManager { #private; constructor(bot: AoiClient, options?: ApplicationCommandManagerOptions); /** * Load all application commands inside a directory. * @param dir - Application commands directory. * @throws {CommandManagerError} If the directory is invalid or commands are invalid */ load(dir: string): Promise<void>; /** * Sync all application commands with the Discord API. * @param guildIDs - Optional array of guild IDs to sync commands to * @throws {CommandManagerError} If guild IDs are invalid or sync fails */ sync(guildIDs?: string[]): Promise<void>; /** * Clear all cached commands. * @returns {ApplicationCommandManager} */ clearCommands(): ApplicationCommandManager; /** * Returns the number of cached commands. * @returns {number} */ commandSize(): number; /** * Get all registered commands * @returns {ApplicationCommandDataResolvable[]} */ getCommands(): ApplicationCommandDataResolvable[]; /** * Command specifications directory. */ get directory(): string | null; }