EventHandler

EventHandler

Class that handles Discord events.

Constructor

# new EventHandler()

Methods

# (static) addEventDirectory(dir) → {module:handlers/EventHandler~EventHandler}

Add a directory to scan for events.

Parameters:
Name Type Description
dir String

The absolute path of the directory to add.

Returns:

A reference to the CommandHandler class.

Type
module:handlers/EventHandler~EventHandler
Example
// Adds the directory "events" to the event handler.

const { join } = require("path");

EventHandler.addEventDirectory(join(__dirname, "events"));

# (static) attachClient(client) → {module:handlers/EventHandler~EventHandler}

Attach a client to the EventHandler.

Parameters:
Name Type Description
client module:discord.js~Client

The Discord client to attach.

Returns:

A reference to the EventHandler class.

Type
module:handlers/EventHandler~EventHandler

# (static) loadEvents() → {module:handlers/EventHandler~EventHandler}

Load all events.

Returns:

A reference to the EventHandler class.

Type
module:handlers/EventHandler~EventHandler
Example
// Load all events in the directory "events"

const { join } = require("path");

EventHandler.addEventDirectory(join(__dirname, "events"));
EventHandler.loadEvents();

# (static) removeEventDirectory(dir) → {module:handlers/EventHandler~EventHandler}

Remove a directory to scan for events.

Parameters:
Name Type Description
dir String

The absolute path of the directory to remove.

Returns:

A reference to the EventHandler class.

Type
module:handlers/EventHandler~EventHandler
Example
// Removes the directory "events" from the event handler.

const { join } = require("path");

EventHandler.removeEventDirectory(join(__dirname, "events"));