Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messageReactionRemove firing twice #3268

Closed
1 task done
bsantosh909 opened this issue May 14, 2019 · 3 comments · Fixed by #3277
Closed
1 task done

messageReactionRemove firing twice #3268

bsantosh909 opened this issue May 14, 2019 · 3 comments · Fixed by #3277

Comments

@bsantosh909
Copy link

Please describe the problem you are having in as much detail as possible:

When I run the code below the messageReactionRemove event fires twice incorrectly. Sample test screenshots below where the reaction count goes to zero as per the code, but the reaction by first user is still available.

Its happening when I include the code:

if (reaction.count > 1) await reaction.users.remove(user);

image

image

Include a reproducible code sample here, if possible:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageReactionAdd', async (reaction, user) => {
  if (reaction.emoji.name !== '⭐') return;
  console.log(`Reaction added by ${user.tag}! New star count ${reaction.count}`);
  if (reaction.count > 1) await reaction.users.remove(user);
});

client.on('messageReactionRemove', (reaction, user) => {
  if (reaction.emoji.name !== '⭐') return;
  console.log(`Reaction removed by ${user.tag}! New star count ${reaction.count}`);
});

client.login('TOKEN');

Further details:

  • discord.js version: Master#72dd872

  • Node.js version: 10.15.3

  • Operating system:

  • Priority this issue should have – please be realistic and elaborate if possible: 😕 Not sure

  • I have also tested the issue on latest master, commit hash:

@Supernalboot
Copy link

Supernalboot commented May 14, 2019

Seems like the first use add a star star = 1 which doesn't trigger if (reaction.count > 1) await reaction.users.remove(user);. but if a second user reacts star = 2 it triggers if (reaction.count > 1) await reaction.users.remove(user); making star = 1 and then triggers.

client.on('messageReactionRemove', (reaction, user) => { if (reaction.emoji.name !== '⭐') return; console.log(Reaction removed by ${user.tag}! New star count ${reaction.count}); });

which I'm assuming changes the count down by 1 making star = 0

I'm not sure but I think what's happening is you're removing the user that created the second star but the messageReactionRemove part is seeing only 1 since you removed the user even though there is 2 for discord.

@bsantosh909
Copy link
Author

@Supernalboot I guess you are not getting my point.

The issue I am having is, when I call reaction.users.remove(user) It should be firing the messageReactionRemove event once.

But as seen in the screenshot below its firing twice and for the same user.
The last two lines in the screenshot are fired by the codes itself i.e. reaction.users.remove(user|) code.
image

And again the screenshot below shows that the reaction from first user is still there (as for discord) but there is no reaction (as for discord.js)
image

@KhooHaoYit
Copy link
Contributor

I think it has the same issue as #3252.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants