diff options
| author | khazhyk <[email protected]> | 2016-11-23 21:51:43 -0800 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-11-30 16:47:00 -0500 |
| commit | c8fd8a9e1ad3485b8bb1efb6ac51baf4b0db21d2 (patch) | |
| tree | 562aee509c555df0ce1fe06cd003691db4ba7028 | |
| parent | Version bump to v0.15.0 (diff) | |
| download | discord.py-c8fd8a9e1ad3485b8bb1efb6ac51baf4b0db21d2.tar.xz discord.py-c8fd8a9e1ad3485b8bb1efb6ac51baf4b0db21d2.zip | |
Fix crash on duplicate or out of order reactions.
Eventual consistency ftw
| -rw-r--r-- | discord/state.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/discord/state.py b/discord/state.py index 6a75491e..d089a5ed 100644 --- a/discord/state.py +++ b/discord/state.py @@ -287,8 +287,11 @@ class ConnectionState: emoji = self._get_reaction_emoji(**data['emoji']) reaction = utils.get(message.reactions, emoji=emoji) - # if reaction isn't in the list, we crash. This means discord - # sent bad data, or we stored improperly + # Eventual consistency means we can get out of order or duplicate removes. + if not reaction: + log.warning("Unexpected reaction remove {}".format(data)) + return + reaction.count -= 1 if data['user_id'] == self.user.id: reaction.me = False |