Baileys
Baileys copied to clipboard
Get removed reactions
The messages.reaction event fires only when you set or change a reaction. Is there any way to tell if the reaction has been removed?
It is documented, look at the link that I give you https://whiskeysockets.github.io/Baileys/index.html
It is documented, look at the link that I give you https://whiskeysockets.github.io/Baileys/index.html
I would like an event to identify that the reaction has been removed. The "messages.reaction" event does not fire when removing.
Well you have to manually record all the reactions and their sender id that a message has received
When receiving an empty reaction (ie. removing the reaction), then you can check what this sender's reaction emoji was.
But the problem is that the "messages.reaction" event is not fired when the reaction is empty
Well you have to manually record all the reactions and their sender id that a message has received
When receiving an empty reaction (ie. removing the reaction), then you can check what this sender's reaction emoji was.
@IanosJunior The reason why the messages.reaction
event is not fired when the reactionMessage.text
is empty is probably in here, but I'm still trying to understand the code.
https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/event-buffer.ts#LL433C27-L433C27
@IanosJunior Found it! The event-buffer
calls the util function updateMessageWithReaction
that in turn checks if the reaction text has a value before pushing the reaction to the message object:
https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/messages.ts#L719
Since the reactionMessage.text
is empty, it will not be pushed, and (I imagine that) when the event-buffer
gets flushed, the messages.reaction
is not fired because this specific reaction is not in the message's "reaction list".
@IanosJunior Found it! The
event-buffer
calls the util functionupdateMessageWithReaction
that in turn checks if the reaction text has a value before pushing the reaction to the message object:https://github.com/WhiskeySockets/Baileys/blob/54f8215eef2ec8911ac0fd71bdf5e2a362f98fcb/src/Utils/messages.ts#L719
Since the
reactionMessage.text
is empty, it will not be pushed, and (I imagine that) when theevent-buffer
gets flushed, themessages.reaction
is not fired because this specific reaction is not in the message's "reaction list".
In this case, it would be better to remove this conditional to know when the reaction was removed. What do you think @matheusb-comp ?
@IanosJunior Just removing this conditional would make these "reactions with empty text" to be added to the msg.reactions
array.
Since the updateMessageWithReaction
function is called in multiple points in the code (including the event-buffer
), I don't know what problems this could cause.
What I'm doing to handle this (in my custom "data-store") is to ignore the messages.reaction
event and emit custom events inside the sock.ev.on("messages.upsert", ...)
based on the message.reactionMessage.text
.
So, let discuss about this, what we can do? Change the messages.reaction
to include empty reaction (remove) or create a new event (maybe messages.reaction.delete
)
👍 for update messages.reaction
with empty reaction
😄 for messages.reaction.delete
(or other name)
So, let discuss about this, what we can do? Change the
messages.reaction
to include empty reaction (remove) or create a new event (maybemessages.reaction.delete
)👍 for update
messages.reaction
with empty reaction 😄 formessages.reaction.delete
(or other name)
In the tests I did, just removing the conditional already solves the problem. I don't know if it might impact storage.
So, let discuss about this, what we can do? Change the
messages.reaction
to include empty reaction (remove) or create a new event (maybemessages.reaction.delete
)👍 for update
messages.reaction
with empty reaction 😄 formessages.reaction.delete
(or other name)
So, will we have an update on this? I got myself stuck because of removed reactions aren't emitted.
Is this still an issue? Assigning myself to test this later!
Forgot to follow up, still an issue, will fix