diff options
author | Minteck <contact@minteck.org> | 2022-07-13 23:34:21 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-07-13 23:34:21 +0200 |
commit | 7b5df4ca0a5bd6fcf033ef40563599593b156910 (patch) | |
tree | 56cb89f3900adde9da67e7558793a20fb40d7197 /core/CommandInteractionManager.ts | |
download | cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.tar.gz cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.tar.bz2 cooler-pony-7b5df4ca0a5bd6fcf033ef40563599593b156910.zip |
Initial commit
Diffstat (limited to 'core/CommandInteractionManager.ts')
-rw-r--r-- | core/CommandInteractionManager.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/CommandInteractionManager.ts b/core/CommandInteractionManager.ts new file mode 100644 index 0000000..0f7cb49 --- /dev/null +++ b/core/CommandInteractionManager.ts @@ -0,0 +1,21 @@ +import {InteractionManager} from "./InteractionManager"; +import {CommandInteraction} from "discord.js"; +import {LogManager} from "./LogManager"; +import {CommandsLoader} from "./CommandsLoader"; +import {CommandAction} from "./CommandAction"; + +export class CommandInteractionManager extends InteractionManager { + public static commands = new CommandsLoader().getCommands(); + + constructor(interaction: CommandInteraction) { + super(); + LogManager.verbose("CommandInteractionManager: " + interaction.commandName); + + if (Object.keys(CommandInteractionManager.commands).includes(interaction.commandName)) { + CommandInteractionManager.commands[interaction.commandName].handle(new CommandAction(interaction.commandName, interaction)); + } else { + LogManager.error("Command not found: " + interaction.commandName); + interaction.reply(":x: Command not found: `" + interaction.commandName + "`, this is most likely a bug."); + } + } +}
\ No newline at end of file |