diff --git a/.github/workflows/dev-commandkit.yaml b/.github/workflows/dev-commandkit.yaml index 31d0e75..d5246f2 100644 --- a/.github/workflows/dev-commandkit.yaml +++ b/.github/workflows/dev-commandkit.yaml @@ -3,7 +3,7 @@ name: (CommandKit) Publish Dev Build on: push: branches: - - master + - main paths: - 'packages/commandkit/**' diff --git a/.github/workflows/dev-create-commandkit.yaml b/.github/workflows/dev-create-commandkit.yaml index bc156ab..956b00e 100644 --- a/.github/workflows/dev-create-commandkit.yaml +++ b/.github/workflows/dev-create-commandkit.yaml @@ -3,7 +3,7 @@ name: (Create CommandKit) Publish Dev Build on: push: branches: - - master + - main paths: - 'packages/create-commandkit/**' diff --git a/packages/commandkit/src/CommandKit.ts b/packages/commandkit/src/CommandKit.ts index 1b29981..ea92dca 100644 --- a/packages/commandkit/src/CommandKit.ts +++ b/packages/commandkit/src/CommandKit.ts @@ -1,12 +1,6 @@ -import type { - CommandKitData, - CommandKitOptions, - ReloadOptions, -} from './typings'; +import type { CommandKitData, CommandKitOptions, ReloadOptions } from './types'; import type { CommandObject } from './types'; - import { CommandHandler, EventHandler, ValidationHandler } from './handlers'; - import colors from './utils/colors'; export class CommandKit { @@ -17,7 +11,7 @@ export class CommandKit { * Create a new command and event handler with CommandKit. * * @param options - The default CommandKit configuration. - * @see {@link https://commandkit.js.org/docs/commandkit-setup} + * @see {@link https://commandkit.js.org/guide/commandkit-setup} */ constructor(options: CommandKitOptions) { if (!options.client) { diff --git a/packages/commandkit/src/handlers/command-handler/CommandHandler.ts b/packages/commandkit/src/handlers/command-handler/CommandHandler.ts index d50e58c..35f3cad 100644 --- a/packages/commandkit/src/handlers/command-handler/CommandHandler.ts +++ b/packages/commandkit/src/handlers/command-handler/CommandHandler.ts @@ -3,7 +3,7 @@ import type { CommandHandlerOptions, CommandKitInteraction, } from './typings'; -import type { CommandFileObject, ReloadOptions } from '../../typings'; +import type { CommandFileObject, ReloadOptions } from '../../types'; import { toFileURL } from '../../utils/resolve-file-url'; import { getFilePaths } from '../../utils/get-paths'; diff --git a/packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts b/packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts index 648cd9d..1aabc13 100644 --- a/packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts +++ b/packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts @@ -1,5 +1,5 @@ import type { ApplicationCommandDataResolvable, Client } from 'discord.js'; -import type { CommandFileObject, ReloadOptions } from '../../../typings'; +import type { CommandFileObject, ReloadOptions } from '../../../types'; import colors from '../../../utils/colors'; diff --git a/packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts b/packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts index 72e07bc..434e822 100644 --- a/packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts +++ b/packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts @@ -5,7 +5,7 @@ import type { GuildApplicationCommandManager, ApplicationCommandDataResolvable, } from 'discord.js'; -import type { CommandFileObject, ReloadOptions } from '../../../typings'; +import type { CommandFileObject, ReloadOptions } from '../../../types'; import areSlashCommandsDifferent from '../utils/areSlashCommandsDifferent'; diff --git a/packages/commandkit/src/handlers/command-handler/typings.ts b/packages/commandkit/src/handlers/command-handler/typings.ts index 78f530c..d5137b5 100644 --- a/packages/commandkit/src/handlers/command-handler/typings.ts +++ b/packages/commandkit/src/handlers/command-handler/typings.ts @@ -5,7 +5,7 @@ import type { ContextMenuCommandInteraction, } from 'discord.js'; import type { CommandKit } from '../../CommandKit'; -import type { CommandFileObject } from '../../typings'; +import type { CommandFileObject } from '../../types'; import type { ValidationHandler } from '../validation-handler/ValidationHandler'; /** diff --git a/packages/commandkit/src/types/index.ts b/packages/commandkit/src/types.ts similarity index 63% rename from packages/commandkit/src/types/index.ts rename to packages/commandkit/src/types.ts index 173732d..1867417 100644 --- a/packages/commandkit/src/types/index.ts +++ b/packages/commandkit/src/types.ts @@ -1,14 +1,129 @@ import type { - RESTPostAPIApplicationCommandsJSONBody, - MessageContextMenuCommandInteraction, - UserContextMenuCommandInteraction, - ContextMenuCommandInteraction, - ChatInputCommandInteraction, AutocompleteInteraction, - PermissionsString, + CacheType, + ChatInputCommandInteraction, Client, + ContextMenuCommandInteraction, + Interaction, + MessageContextMenuCommandInteraction, + PermissionsString, + RESTPostAPIApplicationCommandsJSONBody, + UserContextMenuCommandInteraction, } from 'discord.js'; -import type { CommandKit } from '../CommandKit'; + +import type { CommandKit } from './CommandKit'; +import { CommandHandler, EventHandler, ValidationHandler } from './handlers'; + +/** + * Options for instantiating a CommandKit handler. + */ +export interface CommandKitOptions { + /** + * The Discord.js client object to use with CommandKit. + */ + client: Client; + + /** + * The path to your commands directory. + */ + commandsPath?: string; + + /** + * The path to your events directory. + */ + eventsPath?: string; + + /** + * The path to the validations directory. + */ + validationsPath?: string; + + /** + * List of development guild IDs to restrict devOnly commands to. + */ + devGuildIds?: string[]; + + /** + * List of developer user IDs to restrict devOnly commands to. + */ + devUserIds?: string[]; + + /** + * List of developer role IDs to restrict devOnly commands to. + */ + devRoleIds?: string[]; + + /** + * Skip CommandKit's built-in validations (for devOnly commands). + */ + skipBuiltInValidations?: boolean; + + /** + * Bulk register application commands instead of one-by-one. + */ + bulkRegister?: boolean; + /** + * Options for experimental features. + */ + experimental?: { + /** + * Enable hooks. This allows you to utilize hooks such as `useInteraction()` to access the interaction object anywhere inside the command. + */ + hooks?: boolean; + }; +} + +/** + * Private data for the CommandKit class. + */ +export interface CommandKitData extends CommandKitOptions { + commandHandler?: CommandHandler; + eventHandler?: EventHandler; + validationHandler?: ValidationHandler; +} + +/** + * Represents a command context. + */ +export interface CommandContext< + T extends Interaction, + Cached extends CacheType, +> { + /** + * The interaction that triggered this command. + */ + interaction: Interaction; + /** + * The client that instantiated this command. + */ + client: Client; + /** + * The command data. + */ + handler: CommandKit; +} + +/** + * Represents a command file. + */ +export interface CommandFileObject { + data: CommandData; + options?: CommandOptions; + run: ( + ctx: CommandContext, + ) => Awaited; + autocomplete?: ( + ctx: CommandContext, + ) => Awaited; + filePath: string; + category: string | null; + [key: string]: any; +} + +/** + * A reload type for commands. + */ +export type ReloadOptions = 'dev' | 'global' | ReloadType; /** * Props for command run functions. diff --git a/packages/commandkit/src/typings.ts b/packages/commandkit/src/typings.ts deleted file mode 100644 index fa6148c..0000000 --- a/packages/commandkit/src/typings.ts +++ /dev/null @@ -1,126 +0,0 @@ -// This types file is for development -// For exported types use ./types/index.ts - -import type { CacheType, Client, Interaction } from 'discord.js'; -import type { - CommandData, - CommandKit, - CommandOptions, - ReloadType, -} from './index'; -import type { - CommandHandler, - EventHandler, - ValidationHandler, -} from './handlers'; - -/** - * Options for instantiating a CommandKit handler. - */ -export interface CommandKitOptions { - /** - * The Discord.js client object to use with CommandKit. - */ - client: Client; - - /** - * The path to your commands directory. - */ - commandsPath?: string; - - /** - * The path to your events directory. - */ - eventsPath?: string; - - /** - * The path to the validations directory. - */ - validationsPath?: string; - - /** - * List of development guild IDs to restrict devOnly commands to. - */ - devGuildIds?: string[]; - - /** - * List of developer user IDs to restrict devOnly commands to. - */ - devUserIds?: string[]; - - /** - * List of developer role IDs to restrict devOnly commands to. - */ - devRoleIds?: string[]; - - /** - * Skip CommandKit's built-in validations (for devOnly commands). - */ - skipBuiltInValidations?: boolean; - - /** - * Bulk register application commands instead of one-by-one. - */ - bulkRegister?: boolean; - /** - * Options for experimental features. - */ - experimental?: { - /** - * Enable hooks. This allows you to utilize hooks such as `useInteraction()` to access the interaction object anywhere inside the command. - */ - hooks?: boolean; - }; -} - -/** - * Private data for the CommandKit class. - */ -export interface CommandKitData extends CommandKitOptions { - commandHandler?: CommandHandler; - eventHandler?: EventHandler; - validationHandler?: ValidationHandler; -} - -/** - * Represents a command context. - */ -export interface CommandContext< - T extends Interaction, - Cached extends CacheType, -> { - /** - * The interaction that triggered this command. - */ - interaction: Interaction; - /** - * The client that instantiated this command. - */ - client: Client; - /** - * The command data. - */ - handler: CommandKit; -} - -/** - * Represents a command file. - */ -export interface CommandFileObject { - data: CommandData; - options?: CommandOptions; - run: ( - ctx: CommandContext, - ) => Awaited; - autocomplete?: ( - ctx: CommandContext, - ) => Awaited; - filePath: string; - category: string | null; - [key: string]: any; -} - -/** - * A reload type for commands. - */ -export type ReloadOptions = 'dev' | 'global' | ReloadType;