Add RawReactionActionEvent.event_type attribute.
This helps differentiate between reaction removal or addition.
This commit is contained in:
parent
ceaba01776
commit
f513d831d1
@ -112,6 +112,9 @@ class RawReactionActionEvent(_RawReprMixin):
|
|||||||
"""Represents the payload for a :func:`on_raw_reaction_add` or
|
"""Represents the payload for a :func:`on_raw_reaction_add` or
|
||||||
:func:`on_raw_reaction_remove` event.
|
:func:`on_raw_reaction_remove` event.
|
||||||
|
|
||||||
|
.. versionchanged:: 1.3.0
|
||||||
|
The ``event_type`` attribute was added.
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
-----------
|
-----------
|
||||||
message_id: :class:`int`
|
message_id: :class:`int`
|
||||||
@ -124,15 +127,20 @@ class RawReactionActionEvent(_RawReprMixin):
|
|||||||
The guild ID where the reaction got added or removed, if applicable.
|
The guild ID where the reaction got added or removed, if applicable.
|
||||||
emoji: :class:`PartialEmoji`
|
emoji: :class:`PartialEmoji`
|
||||||
The custom or unicode emoji being used.
|
The custom or unicode emoji being used.
|
||||||
|
event_type: :class:`str`
|
||||||
|
The event type that triggered this action. Can be
|
||||||
|
``REACTION_ADD`` for reaction addition or
|
||||||
|
``REACTION_REMOVE`` for reaction removal.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__slots__ = ('message_id', 'user_id', 'channel_id', 'guild_id', 'emoji')
|
__slots__ = ('message_id', 'user_id', 'channel_id', 'guild_id', 'emoji')
|
||||||
|
|
||||||
def __init__(self, data, emoji):
|
def __init__(self, data, emoji, event_type):
|
||||||
self.message_id = int(data['message_id'])
|
self.message_id = int(data['message_id'])
|
||||||
self.channel_id = int(data['channel_id'])
|
self.channel_id = int(data['channel_id'])
|
||||||
self.user_id = int(data['user_id'])
|
self.user_id = int(data['user_id'])
|
||||||
self.emoji = emoji
|
self.emoji = emoji
|
||||||
|
self.event_type = event_type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.guild_id = int(data['guild_id'])
|
self.guild_id = int(data['guild_id'])
|
||||||
|
@ -437,7 +437,7 @@ class ConnectionState:
|
|||||||
emoji_data = data['emoji']
|
emoji_data = data['emoji']
|
||||||
emoji_id = utils._get_as_snowflake(emoji_data, 'id')
|
emoji_id = utils._get_as_snowflake(emoji_data, 'id')
|
||||||
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
|
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
|
||||||
raw = RawReactionActionEvent(data, emoji)
|
raw = RawReactionActionEvent(data, emoji, 'REACTION_ADD')
|
||||||
self.dispatch('raw_reaction_add', raw)
|
self.dispatch('raw_reaction_add', raw)
|
||||||
|
|
||||||
# rich interface here
|
# rich interface here
|
||||||
@ -463,7 +463,7 @@ class ConnectionState:
|
|||||||
emoji_data = data['emoji']
|
emoji_data = data['emoji']
|
||||||
emoji_id = utils._get_as_snowflake(emoji_data, 'id')
|
emoji_id = utils._get_as_snowflake(emoji_data, 'id')
|
||||||
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
|
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
|
||||||
raw = RawReactionActionEvent(data, emoji)
|
raw = RawReactionActionEvent(data, emoji, 'REACTION_REMOVE')
|
||||||
self.dispatch('raw_reaction_remove', raw)
|
self.dispatch('raw_reaction_remove', raw)
|
||||||
|
|
||||||
message = self._get_message(raw.message_id)
|
message = self._get_message(raw.message_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user