Skip to content

Commit c88bff4

Browse files
authored
Merge pull request #518 from underctrl-io/no-cli-error
feat: add proper no cli error
2 parents 5685f97 + cb88a4d commit c88bff4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/commandkit/hooks.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
CommandKitEnvironment,
66
EventWorkerContext,
77
} from './dist/index.js';
8-
import type { Client } from 'discord.js';
8+
import type { Client, Collection } from 'discord.js';
99

1010
export function useAnyEnvironment(): CommandKitEnvironment | EventWorkerContext;
1111

@@ -16,3 +16,5 @@ export function useCommandKit(): CommandKit;
1616
export function useCommand(): LoadedCommand;
1717

1818
export function useEvent(): ParsedEvent;
19+
20+
export function useStore<K = any, V = any>(): Collection<K, V>;

packages/commandkit/src/commandkit.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,13 @@ export class CommandKit extends EventEmitter {
370370

371371
async #init() {
372372
const appDir = this.getAppDirectory();
373-
if (!appDir) return;
373+
if (!appDir) {
374+
throw new Error(
375+
'CommandKit could not determine the application directory. ' +
376+
'This issue is common when you are not using the `commandkit dev` command to start the project. ' +
377+
'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).',
378+
);
379+
}
374380

375381
const commandsPath = this.getPath('commands')!;
376382
const events = this.getPath('events')!;

0 commit comments

Comments
 (0)