From 7b5df4ca0a5bd6fcf033ef40563599593b156910 Mon Sep 17 00:00:00 2001 From: Minteck Date: Wed, 13 Jul 2022 23:34:21 +0200 Subject: Initial commit --- core/CommandInteractionManager.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 core/CommandInteractionManager.ts (limited to 'core/CommandInteractionManager.ts') 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 -- cgit