Class: Handler

Handler(opts)

new Handler(opts)

Create a new command handler

Parameters:
Name Type Description
opts HandlerConstructor

Put all options in this object. Only the client, prefix and commands directory are requred, everthing else is optional.

Source:

Methods

(async) dbConnect(uri)

Connect to the database (for cooldowns)

Parameters:
Name Type Description
uri string

MongoDB connection string

Source:

(async) executeCommand(message, command)

Execute a command. (this is the function used internally for launching the commands)

Parameters:
Name Type Description
message Discord.Message

The message that contains the command

command Command

The command to execute. (pro tip: combine with handler.getCommand)

Source:
Returns:

void

getCommand(name)

Find a command from any of its aliases (this is the function used internally for finding commands)

Parameters:
Name Type Description
name string

Name or names of a command

Source:
Returns:

The command or undefined if no command was found

listen()

Listen for messages

Source:

(async) loadCommands(dir, reload)

Recursively reads a directory and loads all .js and .ts files (if these files don't export a command they will just be ignored)

Parameters:
Name Type Default Description
dir string

The directory to use

reload boolean false

Whether to clear the command list before reading (useful to reload the commands)

Source:

makeEmbed(title, desc, color, thumbnail)

A utility function to create nice embeds.

Parameters:
Name Type Description
title
desc
color
thumbnail
Source: