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 maxInterfaces
Number 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 command
ReactCommand The react command object
data
Object Situational data
Properties:
Name Type Description data.msg
Eris.Message The message that was reacted on
data.user
Eris.User The user that reacted
-
private _getInterfaceButton(msg, emoji) → {ReactInterface|undefined}
-
Get a bound interface button of a message
Parameters:
Name Type Description msg
Eris.Message The message
emoji
Object 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 data
Object Situational data
options
Object The options for the response
Returns:
Promise<Eris.Message> -Overall results from the react command
Properties:
Name Type Description data.msg
Eris.Message The message that was reacted on
data.user
Eris.User The user that reacted
options.channel
String The ID of the channel the response was sent to
options.awaits
Array<Await> | Await An action or list of actions that are awaited after the results are processed
options.reactInterface
ReactInterface A react interface that is bound to the resulting message
options.deleteAfter
Number How long until the response is deleted
response
Eris.Message | Error The response that was sent to Discord
-
private _loadReactCommand(reactCommand)
-
Load a reaction command
Parameters:
Name Type Description reactCommand
ReactCommand The reaction command to load
-
async bindInterface(msg, reactInterface, _defaultDesignated) → {Promise<ReactInterface>}
-
Bind an interface to a command
Parameters:
Name Type Description msg
Eris.Message The message to bind to
reactInterface
ReactInterface The interface to bind
_defaultDesignated
String The default designated user (generally the command initiator)
-
async detachInterface(msg, removeButtons : opt) → {Promise<ReactInterface>}
-
Parameters:
Name Type Attributes Default Description msg
Eris.Message The message to detach the interface from
removeButtons
Boolean <optional>
true Whether the buttons from the message are removed
-
getReactCommand(emoji) → {ReactCommand|undefined}
-
Get a react command
Parameters:
Name Type Description emoji
String The emoji that triggers the react command
-
async handle(msg, emoji, user) → {Promise<ReactionHandlerResultList>}
-
Handle an incoming Discord reaction
Parameters:
Name Type Description msg
Eris.Message The message reacted on
emoji
Object The data of the emoji reacted with
user
Eris.User The user who reacted
-
loadReactCommands(reactCommands)
-
Load reaction commands
Parameters:
Name Type Description reactCommands
Array<ReactCommand> | ReactCommand The reaction command(s) to load