Discordia
Discordia copied to clipboard
Reaction hash is not unique to the reaction object
The hashes of two or more reactions from different messages are equal when they represent the same emoji. This results in Container:__eq()
returning true
for the reaction objects, even if they are on different messages. This behavior may be unintuitive, but fixing the __eq
behavior would require changing the reaction hash format.
This will almost certainly not change until the next major version of Discordia.
I have not defined __hash
methods in 3.0 yet. I'm not sure if I will at this point, but I do have an __eq
method for the Reaction
class that will resolve this issue:
function Reaction:__eq(other)
return self.messageId == other.messageId and self.emojiHash == other.emojiHash
end
Update:
I've added an "unflattened" ReactionEmoji
struct class that is accessible at the emoji
property AND added a hash
property that returns emoji.id
for custom emojis or emoji.name
for standard unicode emojis. This is NOT the same as emoji.hash
, which is the concatenation of emoji.name
and emoji.id
for HTTP requests with custom emojis.
The __eq
method has therefore been changed to:
function Reaction:__eq(other)
return self.messageId == other.messageId and self.hash == other.hash
end