ReactionCollector

ReactionCollector

Reaction Collector class

Constructor

new ReactionCollector()

Source:

Methods

(async, static) menu(options, …argsopt) → {Controller}

Source:
Parameters:
Name Type Attributes Description
options Object

Options to create a reaction menu.

Name Type Attributes Description
botMessage Message

Bot message where collector will start work.

pages Object

Reaction menu pages.

user UserResolvable

User who can react this menu.

collectorOptions Discord.ReactionCollectorOptions <optional>

Options to create discord.js reaction collector options.

args * <optional>
<repeatable>

Arguments given when onReact or onMessage function was triggered.

Returns:
Type:
Controller

(async, static) paginator(options)

This method can be used to create easier react pagination, with multiple embeds pages.

Source:
Parameters:
Name Type Description
options PaginatorOptions
Name Type Attributes Default Description
botMessage Message

Message from Bot to create reaction collector.

user UserResolvable

UserResolvable who will react.

pages Array.<MessageEmbed>

Array with embeds.

reactions Array.<EmojiResolvable> <optional>

Array with back/skip reactions.

collectorOptions Discord.ReactionCollectorOptions <optional>
<nullable>

Default discord.js reaction collector options

deleteReaction boolean <optional>
<nullable>
true

The Bot will remove reaction after user react?

deleteAllOnEnd boolean <optional>
<nullable>
true

The Bot will remove reaction after collector end?

Returns:

void

Example
const botMessage = await message.channel.send('Simple paginator...');
  ReactionCollector.paginator({
      botMessage,
      user: message.author,
      pages: [
          new MessageEmbed({ description: 'First page content...' }),
          new MessageEmbed({ description: 'Second page content...' })
      ]
  });

(static) question(options, …argsopt)

This method can be used in multiples emoji choices.

Source:
Parameters:
Name Type Attributes Description
options CollectorOptions
Name Type Attributes Default Description
botMessage Message

Message from Bot to create reaction collector.

user UserResolvable

UserResolvable who will react.

reactions Array.<EmojiResolvable> <optional>
['✅','❌']

Object with reactions and functions.

collectorOptions Discord.ReactionCollectorOptions <optional>
<nullable>

Default discord.js reaction collector options

deleteReaction boolean <optional>
<nullable>
true

The Bot will remove reaction after user react?

deleteAllOnEnd boolean <optional>
<nullable>
true

The Bot will remove reaction after collector end?

args * <optional>
<repeatable>

All args given at trigger onReact() funcion. See example in https://github.com/IDjinn/Discord.js-Collector/tree/master/examples/reaction-collector/question.js

Returns:

Discord.ReactionCollector

(async, static) yesNoQuestion(options) → {Promise.<boolean>}

See full example in https://github.com/IDjinn/Discord.js-Collector/blob/master/examples/reaction-collector/yesNoQuestion.js

This method can be used in async methods, returning only boolean value, more easier to use inside if tratament or two choices.

Source:
Parameters:
Name Type Description
options AsyncCollectorOptions
Name Type Attributes Default Description
botMessage Message

Message from Bot to create reaction collector.

user UserResolvable

UserResolvable who will react.

reactions Array.<EmojiResolvable> <optional>
['✅','❌']

Array with 2 emojis, first one is "Yes" and second one is "No".

collectorOptions Discord.ReactionCollectorOptions <optional>

Default discord.js reaction collector options

deleteReaction boolean <optional>
true

The Bot will remove reaction after user react?

deleteAllOnEnd boolean <optional>
true

The Bot will remove reaction after collector end?

Returns:
Type:
Promise.<boolean>
Example
const botMessage = await message.channel.send('Simple yes/no question');
if (await ReactionCollector.yesNoQuestion({ user: message.author, botMessage }))
    message.channel.send('You\'ve clicked in yes button!');
else
    message.channel.send('You\'ve clicked in no button!');