Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

Commit

Permalink
Fix issue with custom emote IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jowsey authored Dec 27, 2020
1 parent 8cedf84 commit 1e15f56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,16 @@ module.exports.Menu = class extends EventEmitter {
})

this.reactionCollector.on('collect', (reaction, user) => {
// If a 3rd party tries to add reactions or the reaction isn't registered, delete it.
if (user.id !== this.userID || !Object.keys(this.currentPage.reactions).includes(reaction.emoji.name)) {
return reaction.users.remove(user)
}

// If the name exists, prioritise using that, otherwise, use the ID. If neither are in the list, don't run anything.
const reactionName = Object.prototype.hasOwnProperty.call(this.currentPage.reactions, reaction.emoji.name)
? reaction.emoji.name
: Object.prototype.hasOwnProperty.call(this.currentPage.reactions, reaction.emoji.id) ? reaction.emoji.id : null

// If a 3rd party tries to add reactions or the reaction isn't registered, delete it.
if (user.id !== this.userID || !Object.keys(this.currentPage.reactions).includes(reactionName)) {
return reaction.users.remove(user)
}

if (reactionName) {
if (typeof this.currentPage.reactions[reactionName] === 'function') {
return this.currentPage.reactions[reactionName]()
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord.js-menu",
"version": "2.3.0",
"version": "2.3.1",
"description": "💬 Easily create Discord.js embed menus with reactions and unlimited customisable pages.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1e15f56

Please sign in to comment.