diff options
| author | Rapptz <[email protected]> | 2020-01-17 19:48:46 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2020-01-17 19:53:28 -0500 |
| commit | 87f9dcff9c5af9c4fa6e6b148663320522a3c82f (patch) | |
| tree | 2a46dc76aafa9e10ad134c681705684bdb4cf29c /discord/state.py | |
| parent | Add support for on_invite_create and on_invite_delete (diff) | |
| download | discord.py-87f9dcff9c5af9c4fa6e6b148663320522a3c82f.tar.xz discord.py-87f9dcff9c5af9c4fa6e6b148663320522a3c82f.zip | |
Add support for clearing a specific reaction.
Closes #2440
Diffstat (limited to 'discord/state.py')
| -rw-r--r-- | discord/state.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/discord/state.py b/discord/state.py index aea0984d..a3a8e243 100644 --- a/discord/state.py +++ b/discord/state.py @@ -509,6 +509,23 @@ class ConnectionState: if user: self.dispatch('reaction_remove', reaction, user) + def parse_message_reaction_remove_emoji(self, data): + emoji = data['emoji'] + emoji_id = utils._get_as_snowflake(emoji, 'id') + emoji = PartialEmoji.with_state(self, animated=emoji.get('animated', False), id=emoji_id, name=emoji['name']) + raw = RawReactionClearEmojiEvent(data, emoji) + self.dispatch('raw_reaction_clear_emoji', raw) + + message = self._get_message(raw.message_id) + if message is not None: + try: + reaction = message._clear_emoji(emoji) + except (AttributeError, ValueError): # eventual consistency lol + pass + else: + if reaction: + self.dispatch('reaction_clear_emoji', reaction) + def parse_presence_update(self, data): guild_id = utils._get_as_snowflake(data, 'guild_id') guild = self._get_guild(guild_id) |