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

Reactions: msg.deleted returning wrong value causing errors #4

Open
valkyrienyanko opened this issue Apr 25, 2020 · 0 comments
Open
Labels
bug Something isn't working

Comments

@valkyrienyanko
Copy link
Collaborator

valkyrienyanko commented Apr 25, 2020

Context

The exports.trash function reacts to most bot messages with a trash emote. When the user clicks on the trash emote, the bot the message sent will be removed along with the reactions. If the user does not click on the trash emote, the collector will eventually end and the collector end event will be fired removing the trash emote reaction from the message and the message will not be deleted.

Issue

The issue happens when the user clicks on the trash emote, the message gets deleted but the console logs a Discord API Error: Unknown Message with a path indicating that the code is trying to remove reactions from a non-existent message. The issue is msg.deleted is returning false when it should be returning true, thus causing the code to remove reactions from a non-existent message.

Hypothesis

My guess is the collector is ending too fast for the Discord API to catch up and return the correct value onto msg.deleted. I thought of passing in a boolean when collector.stop() is called to stop the code in collector.on('end', => {...} from firing but it seems like a hassle to do all that. There has to be a easier way I'm not seeing.

https://github.com/valkyrienyanko/ValksBot/blob/2862a784b99515edc1dce84af9d0168149aed9cb/modules/React.js#L13-L38

Line 35 is where the code removes the trash emote.

@valkyrienyanko valkyrienyanko added the bug Something isn't working label Apr 25, 2020
@valkyrienyanko valkyrienyanko changed the title Reactions: msg.deleted returning wrong value Reactions: msg.deleted returning wrong value causing errors Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant