Skip to content

Commit

Permalink
chore: added comments and fixed various code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NichArchA82 committed Dec 14, 2024
1 parent d3847d3 commit 9c5576e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions command-handler/src/index.js
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down

0 comments on commit 9c5576e

Please sign in to comment.