new ReactionHandler(data)
Construct a reaction handler
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The reaction handler data |
Properties:
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data.agent |
Agent |
<optional> |
The agent managing the bot |
||||||||||||||||
data.client |
Eris.Client | The Eris client |
|||||||||||||||||
data.reactCommands |
Array<ReactCommand> | ReactCommand |
<optional> |
[] | Array of reaction commands to load initially |
|||||||||||||||
data.options |
Object |
<optional> |
{} | Options for the reaction handler Properties
|
Members
-
private _options : Object
-
The options for the reaction handler
Properties:
Name Type Description maxInterfacesNumber The maximum amount of interfaces cached before they start getting deleted. MINIMUM: 3
-
private _reactCommands : Map<String, ReactCommand>
-
Map of the reaction commands
-
private _reactInterfaces : Map<String, ReactInterface>
-
Map of the interfaces bound to messages
Methods
-
private _commandCleanup(command, data)
-
Tidy up after a react command has finished executing
Parameters:
Name Type Description commandReactCommand The react command object
dataObject Situational data
Properties:
Name Type Description data.msgEris.Message The message that was reacted on
data.userEris.User The user that reacted
-
private _getInterfaceButton(msg, emoji) → {ReactInterface|undefined}
-
Get a bound interface button of a message
Parameters:
Name Type Description msgEris.Message The message
emojiObject The emoji reacted with
-
async, private _implementResponse(data, options) → {Promise<Eris.Message>}
-
Tidy up after a successful response from a react command
Parameters:
Name Type Description dataObject Situational data
optionsObject The options for the response
Returns:
Promise<Eris.Message> -Overall results from the react command
Properties:
Name Type Description data.msgEris.Message The message that was reacted on
data.userEris.User The user that reacted
options.channelString The ID of the channel the response was sent to
options.awaitsArray<Await> | Await An action or list of actions that are awaited after the results are processed
options.reactInterfaceReactInterface A react interface that is bound to the resulting message
options.deleteAfterNumber How long until the response is deleted
responseEris.Message | Error The response that was sent to Discord
-
private _loadReactCommand(reactCommand)
-
Load a reaction command
Parameters:
Name Type Description reactCommandReactCommand The reaction command to load
-
async bindInterface(msg, reactInterface, _defaultDesignated) → {Promise<ReactInterface>}
-
Bind an interface to a command
Parameters:
Name Type Description msgEris.Message The message to bind to
reactInterfaceReactInterface The interface to bind
_defaultDesignatedString The default designated user (generally the command initiator)
-
async detachInterface(msg, removeButtons : opt) → {Promise<ReactInterface>}
-
Parameters:
Name Type Attributes Default Description msgEris.Message The message to detach the interface from
removeButtonsBoolean <optional>
true Whether the buttons from the message are removed
-
getReactCommand(emoji) → {ReactCommand|undefined}
-
Get a react command
Parameters:
Name Type Description emojiString The emoji that triggers the react command
-
async handle(msg, emoji, user) → {Promise<ReactionHandlerResultList>}
-
Handle an incoming Discord reaction
Parameters:
Name Type Description msgEris.Message The message reacted on
emojiObject The data of the emoji reacted with
userEris.User The user who reacted
-
loadReactCommands(reactCommands)
-
Load reaction commands
Parameters:
Name Type Description reactCommandsArray<ReactCommand> | ReactCommand The reaction command(s) to load