diff options
| author | Rapptz <[email protected]> | 2017-06-09 18:36:59 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-06-09 18:36:59 -0400 |
| commit | d239cc26666ff255a0c86c83541ef90f2b586598 (patch) | |
| tree | f7c644f297190cede85b324bdb1d776543523a1e /discord/message.py | |
| parent | Allow sending files list smaller than 2 elements in Messageable.send (diff) | |
| download | discord.py-d239cc26666ff255a0c86c83541ef90f2b586598.tar.xz discord.py-d239cc26666ff255a0c86c83541ef90f2b586598.zip | |
Implement "partial" message events.
These are events that get triggered regardless of the state of the
message cache. Useful for getting data from before the bot was booted.
Diffstat (limited to 'discord/message.py')
| -rw-r--r-- | discord/message.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/discord/message.py b/discord/message.py index 2550798f..27296117 100644 --- a/discord/message.py +++ b/discord/message.py @@ -198,10 +198,9 @@ class Message: else: setattr(self, key, transform(value)) - def _add_reaction(self, data): - emoji = self._state.get_reaction_emoji(data['emoji']) + def _add_reaction(self, data, emoji, user_id): reaction = utils.find(lambda r: r.emoji == emoji, self.reactions) - is_me = data['me'] = int(data['user_id']) == self._state.self_id + is_me = data['me'] = user_id == self._state.self_id if reaction is None: reaction = Reaction(message=self, data=data, emoji=emoji) @@ -213,8 +212,7 @@ class Message: return reaction - def _remove_reaction(self, data): - emoji = self._state.get_reaction_emoji(data['emoji']) + def _remove_reaction(self, data, emoji, user_id): reaction = utils.find(lambda r: r.emoji == emoji, self.reactions) if reaction is None: @@ -225,7 +223,7 @@ class Message: # sent bad data, or we stored improperly reaction.count -= 1 - if int(data['user_id']) == self._state.self_id: + if user_id == self._state.self_id: reaction.me = False if reaction.count == 0: # this raises ValueError if something went wrong as well. |