From 9c5576e9414d1c9062d696a72e5961db6dc1e779 Mon Sep 17 00:00:00 2001 From: Nicholas Archuletta Date: Sat, 14 Dec 2024 17:23:20 +0000 Subject: [PATCH] chore: added comments and fixed various code formatting --- command-handler/src/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/command-handler/src/index.js b/command-handler/src/index.js index 493483f..b9ab5fd 100644 --- a/command-handler/src/index.js +++ b/command-handler/src/index.js @@ -1,18 +1,28 @@ -import cmdHandler from './cmd-handler/command-handler.js'; -import command from './events/legacy-command.js'; -import button from './events/button-click.js'; +/* + Command Handler class +*/ + +import cmdHandler from './cmd-handler/command-handler.js'; // import the command handler +import command from './events/legacy-command.js'; // import the command event +import button from './events/button-click.js'; // import the button click event export default class CommandHandler { constructor({ app, commandsDir }) { + // Check if app is provided if (!app) throw new Error('App is required'); - this._app = app; + this._app = app; // app is the slack app this._commandHandler = null; + // Create a command handler if commands directory is provided if (commandsDir) this._commandHandler = new cmdHandler(commandsDir, app, this); + // Create the command and button event Listeners + // pass the app and this instance of the command handler + // this calls the command and button functions to register the events command(app, this); button(app, this); } + // Getters for the private properties get commandHandler() { return this._commandHandler; }