Trying to detect emojis added to messages

I am attempting to detect when emojis are added to messages and do different things based on the emoji however currently it isn't doing anything. I found a thing mentioning doing it this way so I tried it, I also looked into event handling and tried putting it into its own file, below, and that didn't work either. Neither of them give errors they simply don't print anything. inside of index.js:
client.on(Events.MessageReactionAdd, (reaction) => {
console.log("event entered");
if (reaction.emoji.identifier == 'gold') {
console.log("Reaction emoji gold!");
}
else {
console.log(reaction.emoji.identifier);
}
})
client.on(Events.MessageReactionAdd, (reaction) => {
console.log("event entered");
if (reaction.emoji.identifier == 'gold') {
console.log("Reaction emoji gold!");
}
else {
console.log(reaction.emoji.identifier);
}
})
events/messageReactionAdd.js:
const { Events, MessageFlags } = require('discord.js');

module.exports = {
name: Events.MessageReactionAdd,
async execute(reaction) {
console.log("event entered");
if (reaction.emoji.identifier == 'gold') {
console.log("Reaction emoji gold!");
} else {
console.log(reaction.emoji.identifier);
}
}
};
const { Events, MessageFlags } = require('discord.js');

module.exports = {
name: Events.MessageReactionAdd,
async execute(reaction) {
console.log("event entered");
if (reaction.emoji.identifier == 'gold') {
console.log("Reaction emoji gold!");
} else {
console.log(reaction.emoji.identifier);
}
}
};
12 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Octoboomer
Octoboomer2mo ago
That’s not a valid format for Emoji.identifier You should just check the emoji.id to the custom emoji id that ur checking for
Evena
EvenaOP2mo ago
If that were the problem it would still be either printing something (even if just undefined) or giving an error, but it isn't doing either. I will still make that change, but right now it isn't even entering execute or client.on(Events.MessageReactionAdd
Octoboomer
Octoboomer2mo ago
Is the reaction occurring in a guild?
Evena
EvenaOP2mo ago
Yeah, and the bot can see messages in the guild
Octoboomer
Octoboomer2mo ago
Did you enable the guild message reactions intent?
Evena
EvenaOP2mo ago
I believe so, how can I double check? Nevermind, I found it, I had thought GuildMessages and MessageContent together would include it. unfortunately however adding the intent doesn't fix the issue
Octoboomer
Octoboomer2mo ago
Was the message sent before the bot became ready?
Evena
EvenaOP2mo ago
Ah, yeah. That was the issue. Does there happen to be any way around that issue?
Octoboomer
Octoboomer2mo ago
Enable the message partial
d.js docs
d.js docs2mo ago
:guide: Popular Topics: Partial Structures - Enabling Partials read more
Evena
EvenaOP2mo ago
Thank you, that solved it. ^v^

Did you find this page helpful?