diff options
author | Vendicated <vendicated@riseup.net> | 2022-10-20 19:56:20 +0200 |
---|---|---|
committer | Ven <vendicated@riseup.net> | 2022-10-20 20:23:14 +0200 |
commit | 05051399b6cc7c6821b3df52da82ec9e57e29c22 (patch) | |
tree | cf26640393bde4c92130376ac9fe9c07d2055e54 /src/api | |
parent | e4068ef9a6fb1bb0ec120b776f6d67c6c2f8efac (diff) | |
download | Vencord-05051399b6cc7c6821b3df52da82ec9e57e29c22.tar.gz Vencord-05051399b6cc7c6821b3df52da82ec9e57e29c22.tar.bz2 Vencord-05051399b6cc7c6821b3df52da82ec9e57e29c22.zip |
Fix error when enabling a plugin with commands if CommandsAPI hasn't loaded
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/Commands/index.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/api/Commands/index.ts b/src/api/Commands/index.ts index 6f18f10..aaf0a8e 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.`); |