Fix command hot reloading
This commit is contained in:
parent
6a4021d5ae
commit
41d2330f28
|
@ -174,3 +174,10 @@ export class CommandHandler {
|
|||
for (const prefix of prefixConfig.prefixes) {
|
||||
CommandHandler.prefixes.add(prefix);
|
||||
}
|
||||
|
||||
// Store commands for hot reload
|
||||
declare global {
|
||||
var commandHandler: any;
|
||||
}
|
||||
|
||||
globalThis.commandHandler ??= CommandHandler;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { CommandGroup } from "./CommandGroup";
|
||||
import { CommandHandler } from "./CommandHandler";
|
||||
import { about } from "./commands/general/about";
|
||||
import { help } from "./commands/general/help";
|
||||
import { id } from "./commands/utility/id";
|
||||
|
@ -24,15 +23,15 @@ export function loadCommands() {
|
|||
// cringe
|
||||
const general = new CommandGroup("general", "⭐ General");
|
||||
general.addCommands([help, about]);
|
||||
CommandHandler.addCommandGroup(general);
|
||||
globalThis.commandHandler.addCommandGroup(general);
|
||||
|
||||
const economy = new CommandGroup("economy", "💸 Economy");
|
||||
economy.addCommands([inventory, balance, tree, pick, grow]);
|
||||
CommandHandler.addCommandGroup(economy);
|
||||
globalThis.commandHandler.addCommandGroup(economy);
|
||||
|
||||
const fun = new CommandGroup("fun", "✨ Fun");
|
||||
fun.addCommands([magic8ball]);
|
||||
CommandHandler.addCommandGroup(fun);
|
||||
globalThis.commandHandler.addCommandGroup(fun);
|
||||
|
||||
const utility = new CommandGroup("utility", "🔨 Utility");
|
||||
utility.addCommands([
|
||||
|
@ -48,7 +47,7 @@ export function loadCommands() {
|
|||
permissions,
|
||||
branch
|
||||
]);
|
||||
CommandHandler.addCommandGroup(utility);
|
||||
globalThis.commandHandler.addCommandGroup(utility);
|
||||
}
|
||||
|
||||
export { CommandHandler, CommandGroup };
|
||||
export { CommandGroup };
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
import { loadCommands, CommandHandler, type CommandGroup } from "./commands";
|
||||
import { loadCommands, type CommandGroup } from "./commands";
|
||||
import { CommandHandler } from "./commands/CommandHandler";
|
||||
import { loadRoleConfig } from "./permissions";
|
||||
import { ServiceLoader } from "./services";
|
||||
import { ConsoleAgent } from "./services/console";
|
||||
import { printStartupASCII } from "./util/ascii";
|
||||
|
||||
// Hot reload persistence
|
||||
declare global {
|
||||
var loaded: boolean;
|
||||
var serviceLoader: any;
|
||||
var commandHandler: any;
|
||||
}
|
||||
|
||||
// Set on first run
|
||||
globalThis.loaded ??= false;
|
||||
globalThis.serviceLoader ??= ServiceLoader;
|
||||
globalThis.commandHandler ??= CommandHandler;
|
||||
|
||||
function load() {
|
||||
printStartupASCII();
|
||||
|
|
Loading…
Reference in New Issue