From 05051399b6cc7c6821b3df52da82ec9e57e29c22 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 20 Oct 2022 19:56:20 +0200 Subject: [PATCH] Fix error when enabling a plugin with commands if CommandsAPI hasn't loaded --- src/api/Commands/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index 6f18f10db..aaf0a8ea7 100644 --- a/src/api/Commands/index.ts +++ b/src/api/Commands/index.ts @@ -75,6 +75,15 @@ function modifyOpt(opt: Option | Command) { } export function registerCommand(command: Command, plugin: string) { + if (!BUILT_IN) { + console.warn( + "[CommandsAPI]", + `Not registering ${command.name} as the CommandsAPI hasn't been initialised.`, + "Please restart to use commands" + ); + return; + } + if (BUILT_IN.some(c => c.name === command.name)) throw new Error(`Command '${command.name}' already exists.`);