Skip to content

Commit

Permalink
feat: add RawReactionActionEvent.message_author_id (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv authored Oct 4, 2023
1 parent e38ba27 commit 1f6104d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog/1079.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :attr:`RawReactionActionEvent.message_author_id`.
23 changes: 20 additions & 3 deletions disnake/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TYPE_CHECKING, List, Literal, Optional, Set, Union, cast

from .enums import ChannelType, try_enum
from .utils import get_slots
from .utils import _get_as_snowflake, get_slots

if TYPE_CHECKING:
from .member import Member
Expand Down Expand Up @@ -169,7 +169,7 @@ class RawReactionActionEvent(_RawReprMixin):
This now also includes the correct :attr:`~PartialEmoji.animated` value when a reaction was removed.
member: Optional[:class:`Member`]
The member who added the reaction. Only available if `event_type` is `REACTION_ADD` and the reaction is inside a guild.
The member who added the reaction. Only available if :attr:`event_type` is ``REACTION_ADD`` and the reaction is inside a guild.
.. versionadded:: 1.3
Expand All @@ -179,9 +179,25 @@ class RawReactionActionEvent(_RawReprMixin):
``REACTION_REMOVE`` for reaction removal.
.. versionadded:: 1.3
message_author_id: Optional[:class:`int`]
The ID of the author who created the message that got a reaction.
Only available if :attr:`event_type` is ``REACTION_ADD``.
May also be ``None`` if the message was created by a webhook.
.. versionadded:: 2.10
"""

__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,
Expand All @@ -199,6 +215,7 @@ def __init__(
self.guild_id: Optional[int] = int(data["guild_id"])
except KeyError:
self.guild_id: Optional[int] = None
self.message_author_id: Optional[int] = _get_as_snowflake(data, "message_author_id")


class RawReactionClearEvent(_RawReprMixin):
Expand Down
1 change: 1 addition & 0 deletions disnake/types/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ class _BaseReactionEvent(TypedDict):
# https://discord.com/developers/docs/topics/gateway-events#message-reaction-add
class MessageReactionAddEvent(_BaseReactionEvent):
member: NotRequired[MemberWithUser]
message_author_id: NotRequired[Snowflake]


# https://discord.com/developers/docs/topics/gateway-events#message-reaction-remove
Expand Down

0 comments on commit 1f6104d

Please sign in to comment.