From cb88a4dffe38a2713194505b9fb36650e1423908 Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Sun, 14 Sep 2025 10:24:51 +0545 Subject: [PATCH] feat: add proper no cli error --- packages/commandkit/hooks.d.ts | 4 +++- packages/commandkit/src/commandkit.ts | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/commandkit/hooks.d.ts b/packages/commandkit/hooks.d.ts index 5619460f..d2eb0732 100644 --- a/packages/commandkit/hooks.d.ts +++ b/packages/commandkit/hooks.d.ts @@ -5,7 +5,7 @@ import type { CommandKitEnvironment, EventWorkerContext, } from './dist/index.js'; -import type { Client } from 'discord.js'; +import type { Client, Collection } from 'discord.js'; export function useAnyEnvironment(): CommandKitEnvironment | EventWorkerContext; @@ -16,3 +16,5 @@ export function useCommandKit(): CommandKit; export function useCommand(): LoadedCommand; export function useEvent(): ParsedEvent; + +export function useStore(): Collection; diff --git a/packages/commandkit/src/commandkit.ts b/packages/commandkit/src/commandkit.ts index a4a699ff..c808816f 100644 --- a/packages/commandkit/src/commandkit.ts +++ b/packages/commandkit/src/commandkit.ts @@ -370,7 +370,13 @@ export class CommandKit extends EventEmitter { async #init() { const appDir = this.getAppDirectory(); - if (!appDir) return; + if (!appDir) { + throw new Error( + 'CommandKit could not determine the application directory. ' + + 'This issue is common when you are not using the `commandkit dev` command to start the project. ' + + 'You can either use `commandkit dev` to start the project, or set the `COMMANDKIT_IS_CLI=true` environment variable (Note that adding this to `.env` file may not work).', + ); + } const commandsPath = this.getPath('commands')!; const events = this.getPath('events')!;