Constructor
new ReactionRoleManager(client, optionsopt) → {ReactionRoleManager}
Reaction Role Manager constructor
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
client |
Client
|
Discord js client Object. |
||||||||||||||||||||||||||||||||||||
options |
Object
|
<optional> |
|
Returns:
- Type:
-
ReactionRoleManager
Extends
- EventEmitter
Members
disabledProperty :boolean
Disable RR instead delete?
- Default Value:
- true
- Source:
Type:
-
boolean
(readonly) isReady :boolean
Is Reaction role manager ready?
- Source:
Type:
-
boolean
keepReactions :boolean
Keep reactions if some reaction role is deleted.
- Source:
Type:
-
boolean
(readonly, nullable) mongoDbLink :string
Mongo db connection link.
- Source:
Type:
-
string
(readonly) reactionRoles :Collection.<string, ReactionRole>
ReactionRoles collection
- Source:
Type:
-
Collection.<string, ReactionRole>
(nullable) readyAt :Date
Reaction role manager ready date
- Source:
Type:
-
Date
storage :boolean
Is storage enabled?
- Default Value:
- true
- Source:
Type:
-
boolean
(nullable) storageJsonPath :string
Json storage path
- Source:
Type:
-
string
(readonly) timeouts :Collection.<string, function()>
Timeouts to check toggled roles collection - Internal use.
- Source:
Type:
-
Collection.<string, function()>
Methods
createReactionRole(options) → {Promise.<ReactionRole>}
Create new reaction role.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
Object with options to create new reaction role.
|
Returns:
- Type:
-
Promise.<ReactionRole>
Example
// update your import, add ReactionRoleType.
const { ReactionRoleManager, ReactionRoleType} = require('discord.js-collector');
const role = message.mentions.roles.first();
if (!role) return message.reply('You need mention a role').then(m => m.delete({ timeout: 1000 }));
const emoji = args[1];
if (!emoji) return message.reply('You need use a valid emoji.').then(m => m.delete({ timeout: 1000 }));
const msg = await message.channel.messages.fetch(args[2] || message.id);
if (!role) return message.reply('Message not found! Wtf...').then(m => m.delete({ timeout: 1000 }));
reactionRoleManager.createReactionRole({
message: msg,
roles: [role],
emoji,
type: ReactionRoleType.NORMAL // It's optional, normal by default
});
(async) deleteReactionRole(options, deletedopt) → {Promise.<?ReactionRole>}
This funcion will delete the reaction role from storage.
- Source:
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object
|
|
||||||||||||||||||
deleted |
boolean
|
<optional> |
false |
Is role deleted from guild? |
Returns:
- Type:
-
Promise.<?ReactionRole>
Example
const emoji = args[0];
if (!emoji) return message.reply('You need use a valid emoji.').then(m => m.delete({ timeout: 1000 }));
const msg = await message.channel.messages.fetch(args[1]);
if (!msg) return message.reply('Message not found! Wtf...').then(m => m.delete({ timeout: 1000 }));
await reactionRoleManager.deleteReactionRole({message: msg, emoji});
(async) store(…roles) → {Promise.<void>}
Store updated roles funcion. Note: for json storage, doesn't need give arguments to this funcion.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
roles |
ReactionRole
|
<repeatable> |
All roles to update in database. |
Returns:
- Type:
-
Promise.<void>
Events
allReactionsRemove
Triggered when someone remove reactions from a message.
Properties:
Name | Type | Description |
---|---|---|
message |
Message
|
The message what reaction was removed. |
rolesAffected |
Array.<Role>
|
Roles affected when reactions was removed. |
membersAffected |
Array.<GuildMember>
|
Members affected when reactions was removed. |
reactionsTaken |
number
|
Count of reactions removed from message. |
- Source:
Example
reactionRoleManager.on('allReactionsRemove', (message) => {
console.log(`All reactions from message ${message.id} was removed, all roles was taken and reactions roles deleted.`)
});
debug
Triggered for debug messages.
- Source:
Example
reactionRoleManager.on('debug', (message) => {
console.log(message);
});
missingPermissions
Triggered when the bot doesn't have permissions to manage this role.
Properties:
Name | Type | Description |
---|---|---|
action |
ActionType
|
Is this action to give or to take off these roles? |
member |
GuildMember
|
Member who will not win/lose the role. |
roles |
Array.<Role>
|
Roles what bot cannot manage to give/take to member. |
reactionRole |
ReactionRole
|
Reaction Role what will not given/taken from member. |
- Source:
Example
reactionRoleManager.on('missingPermissions', (action, member, roles, reactionRole) => {
console.log(`Some roles cannot be ${action === 1 ? 'given' : 'taken'} to member \`${member.displayName}\`,
because i don't have permissions to manage these roles: ${roles.map(role => `\`${role.name}\``).join(',')}`);
});
missingRequirements
Triggered when someone tried won role, but not have it requirements.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
requirementType |
RequirementType
|
The missing requirement to win this role. |
|
member |
GuildMember
|
Member who will not win this role. |
|
reactionRole |
ReactionRole
|
This reaction role what the member hasn't the requirements. |
|
requirementsMissing |
object
|
<nullable> |
All things missing to win this role (e.g roles) |
- Source:
Example
reactionRoleManager.on('missingRequirements', (type, member, reactionRole) => {
console.log(`Member '${member.id}' will not win the roles '${reactionRole.roles}', because him hasn't requirement ${type}`);
});
reactionRoleAdd
Triggered when member won a reaction role.
Properties:
Name | Type | Description |
---|---|---|
member |
GuildMember
|
The guild member who won the role. |
role |
Role
|
The guild role what member was won. |
- Source:
Example
reactionRoleManager.on('reactionRoleAdd', (member, role) => {
console.log(member.displayName + ' won the role ' + role.name)
});
reactionRoleRemove
Triggered when member lose a reaction role.
Properties:
Name | Type | Description |
---|---|---|
member |
GuildMember
|
The guild member who lost the role. |
role |
Role
|
The guild role what member was lost. |
- Source:
Example
reactionRoleManager.on('reactionRoleRemove', (member, role) => {
console.log(member.displayName + ' lose the role ' + role.name)
});
ready
Triggered when reaction role manager is ready.
- Source:
Example
reactionRoleManager.on('ready', () => {
console.log('Reaction Role Manager is ready!');
});