From b1ff8038c83b43a1377eb8d7be0779ec656adba8 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 13 Jul 2023 22:08:41 -0400 Subject: [PATCH] Add RawReactionActionEvent.message_author_id field --- discord/raw_models.py | 13 +++++++++---- discord/types/gateway.py | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/discord/raw_models.py b/discord/raw_models.py index 870a1efd3..874edfcc8 100644 --- a/discord/raw_models.py +++ b/discord/raw_models.py @@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE. from __future__ import annotations import datetime -from typing import TYPE_CHECKING, Optional, Set, List, Tuple, Union +from typing import TYPE_CHECKING, Literal, Optional, Set, List, Tuple, Union from .enums import ChannelType, try_enum from .utils import _get_as_snowflake @@ -57,6 +57,7 @@ if TYPE_CHECKING: from .guild import Guild ReactionActionEvent = Union[MessageReactionAddEvent, MessageReactionRemoveEvent] + ReactionActionType = Literal['REACTION_ADD', 'REACTION_REMOVE'] __all__ = ( @@ -196,7 +197,10 @@ class RawReactionActionEvent(_RawReprMixin): The member who added the reaction. Only available if ``event_type`` is ``REACTION_ADD`` and the reaction is inside a guild. .. versionadded:: 1.3 + message_author_id: Optional[:class:`int`] + The author ID of the message being reacted to. Only available if ``event_type`` is ``REACTION_ADD``. + .. versionadded:: 2.4 event_type: :class:`str` The event type that triggered this action. Can be ``REACTION_ADD`` for reaction addition or @@ -205,15 +209,16 @@ class RawReactionActionEvent(_RawReprMixin): .. versionadded:: 1.3 """ - __slots__ = ('message_id', 'user_id', 'channel_id', 'guild_id', 'emoji', 'event_type', 'member') + __slots__ = ('message_id', 'user_id', 'channel_id', 'guild_id', 'emoji', 'event_type', 'member', 'message_author_id') - def __init__(self, data: ReactionActionEvent, emoji: PartialEmoji, event_type: str) -> None: + def __init__(self, data: ReactionActionEvent, emoji: PartialEmoji, event_type: ReactionActionType) -> None: self.message_id: int = int(data['message_id']) self.channel_id: int = int(data['channel_id']) self.user_id: int = int(data['user_id']) self.emoji: PartialEmoji = emoji - self.event_type: str = event_type + self.event_type: ReactionActionType = event_type self.member: Optional[Member] = None + self.message_author_id: Optional[int] = _get_as_snowflake(data, 'message_author_id') try: self.guild_id: Optional[int] = int(data['guild_id']) diff --git a/discord/types/gateway.py b/discord/types/gateway.py index a87b101f0..3175fd9f0 100644 --- a/discord/types/gateway.py +++ b/discord/types/gateway.py @@ -100,6 +100,7 @@ class MessageReactionAddEvent(TypedDict): emoji: PartialEmoji member: NotRequired[MemberWithUser] guild_id: NotRequired[Snowflake] + message_author_id: NotRequired[Snowflake] class MessageReactionRemoveEvent(TypedDict):