ChatHandler

ChatHandler

Handles messages received by the client

Constructor

new ChatHandler(botopt, optionsopt)

Properties:
Name Type Description
bot Bot

The bot

awaits Object

The active awaits

Creates a new ChatHandler

Parameters:
Name Type Attributes Description
bot Bot <optional>

The main client

options Object <optional>

The configuration to use

Properties
Name Type Attributes Default Description
allowSelf Boolean <optional>
false

Allow messages from the bot to be handled

allowBots Boolean <optional>
false

Allow messages from bots to be handled

defaultHelpCommand Object <optional>

Enable the default help command

Properties
Name Type Attributes Default Description
prefix String <optional>
"!"

The prefix to use for the help command

before String <optional>

The text to put as a header

after String <optional>

The text to put as a footer

title String <optional>

The text to put as a title (bolded)

style String <optional>
"extended"

One of the following: basic, extended, embed

Methods

awaitMessage(trigger, action, timeoutopt) → {Number}

Add an await, which will trigger under certain conditions

Parameters:
Name Type Attributes Description
trigger function

A function that takes a Message and returns a Boolean

action function

A function to be executed when trigger returns true

timeout Number <optional>

Delete the await after this many milliseconds

Returns:

The unique id of the await

Type
Number

getHelp(message) → {Promise}

Generate and send a help message

Parameters:
Name Type Description
message Message

The message to respond to

Returns:

The sent message

Type
Promise

run()

Starts listening for messages

stop()

Stops listening for messages