Base

Base

The Base module class. Every module's MainClass must extend from this. DO NOT INSTANTIATE AS IS.

Constructor

new Base(client)

Sets up the base values of all modules, such as a reference to the client, a name, description and help message.

Properties:
Name Type Description
client external:Client

The Discord.js bot client.

name string

The module's name, used for the help command.

description string

The module's description, used for the help command.

help Object

Used to create the help message.

commandText string

The command the bot will be looking for.

color number

The module's description, used for the help command.

auth Array.<external:Snowflake>

The ID of the users that are authorized to run this command. Authorizes everyone if it's empty.

dmEnabled boolean

Whether or not the command can be run from DMs. Defaults to false.

Source:
Parameters:
Name Type Description
client external:Client

The Discord.js bot client.

Members

(readonly) NUMBER_EMOJIS :Array.<string>

Number emojis from 1 to 10.

Source:
Type:
  • Array.<string>

Methods

(async) load(name, fallback) → {Object}

Loads data from the database.

Source:
Parameters:
Name Type Description
name string

The name of the collection to look for. The database has the same name as the module.

fallback Object

The data to be saved in case no save already exists.

Returns:
Type:
Object

The object fetched from the database, or the fallback object if no save exists.

on_message(message)

Callback function called when a message is sent. Defaults to checking for the command and for auth to execute the command.

Source:
Parameters:
Name Type Description
message external:Message

The message that was sent.

(async) save(name, data)

Saves data into the database.

Source:
Parameters:
Name Type Description
name string

The name of the collection to look for. The database has the same name as the module.

data Object

The data to be stored into the database.

(async) saveExists(name)

Checks the database to see if a save already exists.

Source:
Parameters:
Name Type Description
name string

The name of the collection to look for. The database has the same name as the module.

(async) sendChoice(channel, content, emojis, confirmation_emoji, collect_function, remove_function, confirmation_condition, end_function, options) → {external:Message}

Sends a choice message, using reactions. The message will be deleted once the collector is closed by default.

Source:
Parameters:
Name Type Description
channel external:TextChannel | external:DMChannel

The Discord channel the message is sent to.

content string | external:MessageEmbed

The content of that message.

emojis Array.<string>

The emojis to be added as reactions and listened for. Represents the options the user can take.

confirmation_emoji string

The emoji that will be displayed when either the collect and remove functions return true, and the confirmation_condition is fulfilled. Clicking it will close the collector.

collect_function collectionCallback

The callback function called on the collection of a reaction.

remove_function removalCallback

The callback function called on the removal of a reaction. Set to null to use the collect_function.

confirmation_condition confirmationCallback

The callback function called to verify if the collector should be closed on the collection of the confrimation emoji.

end_function endCallback

The callback function called once the collector is closed.

options Object

Options for the message

Name Type Description
dontDelete boolean

Prevents the message from being deleted once the collector is closed.

Returns:
Type:
external:Message

The message that was sent.