Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

ADD: Remove roles when user remove reaction #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions handlers/messageReactionRemove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// eslint-disable-next-line no-unused-vars
const { MessageReaction, User } = require("discord.js");
const ReactionRoleManager = require("../classes/ReactionRoleManager");

/**
* @function
* @param {MessageReaction} messageReaction
* @param {User} user
* @returns {Promise<void>}
*/
module.exports = async (messageReaction, user) => {
const manager = new ReactionRoleManager(messageReaction, user);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a new config setting to enable/disable this behavior, maybe something like removeRolesOnReactionRemove

the line immediately following creating the manager can call something like:

Suggested change
const manager = new ReactionRoleManager(messageReaction, user);
const manager = new ReactionRoleManager(messageReaction, user);
if (!manager.handleRolesOnReactionRemove()) {
return;
}

README will also have to update, instruction text can be something like:

  • removeRolesOnReactionRemove determines whether a user's previously assigned roles are removed when the user removes their reaction (true) or not (false). Note that removeReaction must be false for this to work properly.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy paste for your convenience

- `removeRolesOnReactionRemove` determines whether a user's previously assigned roles are removed when the user removes their reaction (`true`) or not (`false`). Note that `removeReaction` must be `false` for this to work properly.

if (!(await manager.validateInput())) {
return;
}

manager.handleUserReaction();
manager.assignRoles();
};