Why messageReactionAdd do nothing discord.js

我与影子孤独终老i 提交于 2019-12-10 00:19:49

问题


I want to say that I am French, and I apologize for the mistakes.

I try to code a discord bot with node.js, but i have a problem with messageReactionAdd i don't now why he do nothing when i react with an emoji.

My code :

bot.on('messageReactionRemove', (reaction, user) => {
console.log("that work 1");
if(reaction.emoji.name === "white_check_mark") {
    console.log("that work 2");
}})

However i see on this forum it will work for others

thanks for read !


回答1:


Events messageReactionAdd and messageReactionRemove working only for cached messages. You need add raw event to your code for trigger any message. https://github.com/AnIdiotsGuide/discordjs-bot-guide/blob/master/coding-guides/raw-events.md




回答2:


You are doing reaction remove and you need to use Unicode emojis - you can find these online and copy them




回答3:


You should listen to the messageReactionAdd event.
Keep also in mind that ReactionEmoji.name is the Unicode for that emoji: you can get the Unicode symbol by writing a backslash before the emoji, like \:joy:. The Unicode for :white_check_mark: is ✅.

This should be your code:

bot.on('messageReactionAdd', (reaction, user) => {
  console.log("first check");
  if (reaction.emoji.name === "✅") {
    console.log("second check");
  }
});

This will work on every cached message, if you want it to work only on a specific message, try using Message.awaitReactions() or Message.createReactionCollector()



来源:https://stackoverflow.com/questions/53093266/why-messagereactionadd-do-nothing-discord-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!