aboutsummaryrefslogtreecommitdiff
path: root/core/CommandInteractionManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'core/CommandInteractionManager.ts')
-rw-r--r--core/CommandInteractionManager.ts21
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