Fix error when enabling a plugin with commands if CommandsAPI hasn't loaded
This commit is contained in:
parent
e4068ef9a6
commit
05051399b6
1 changed files with 9 additions and 0 deletions
|
@ -75,6 +75,15 @@ function modifyOpt(opt: Option | Command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerCommand(command: Command, plugin: string) {
|
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))
|
if (BUILT_IN.some(c => c.name === command.name))
|
||||||
throw new Error(`Command '${command.name}' already exists.`);
|
throw new Error(`Command '${command.name}' already exists.`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue