Skip to content

Commit

Permalink
fix: Added member data to the raw_reaction_remove event (Pycord-Devel…
Browse files Browse the repository at this point in the history
…opment#2412)

* fix: Added member data to the raw_reaction_remove event

* style(pre-commit): auto fixes from pre-commit.com hooks

* Added changelog.md for adding member data to raw reaction remove

* Update CHANGELOG.md

Signed-off-by: plun1331 <plun1331@gmail.com>

* doc: Updated documentation for the RawReactionActionEvent.member field

---------

Signed-off-by: plun1331 <plun1331@gmail.com>
Co-authored-by: root <root@DESKTOP-U7KGUE3>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: plun1331 <plun1331@gmail.com>
  • Loading branch information
4 people authored Apr 15, 2024
1 parent 2df4ac9 commit c10022c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2417](https://github.com/Pycord-Development/pycord/pull/2417))
- Added `Guild.search_members`.
([#2418](https://github.com/Pycord-Development/pycord/pull/2418))
- Added `member` data to the `raw_reaction_remove` event.
([#2412](https://github.com/Pycord-Development/pycord/pull/2412))

### Fixed

Expand Down
3 changes: 1 addition & 2 deletions discord/raw_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ class RawReactionActionEvent(_RawReprMixin):
emoji: :class:`PartialEmoji`
The custom or unicode emoji being used.
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 the reaction occurs within a guild.
.. versionadded:: 1.3
Expand Down
11 changes: 11 additions & 0 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,17 @@ def parse_message_reaction_remove(self, data) -> None:
emoji_id = utils._get_as_snowflake(emoji, "id")
emoji = PartialEmoji.with_state(self, id=emoji_id, name=emoji["name"])
raw = RawReactionActionEvent(data, emoji, "REACTION_REMOVE")

member_data = data.get("member")
if member_data:
guild = self._get_guild(raw.guild_id)
if guild is not None:
raw.member = Member(data=member_data, guild=guild, state=self)
else:
raw.member = None
else:
raw.member = None

self.dispatch("raw_reaction_remove", raw)

message = self._get_message(raw.message_id)
Expand Down

0 comments on commit c10022c

Please sign in to comment.