Skip to content

Commit

Permalink
feat: add guild & channel properties to ThreadMembersUpdate (#1504
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Damego authored Jul 27, 2023
1 parent 159e020 commit 5c21875
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion interactions/api/events/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class ThreadMemberUpdate(ThreadCreate):


@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class ThreadMembersUpdate(BaseEvent):
class ThreadMembersUpdate(GuildEvent):
"""Dispatched when anyone is added or removed from a thread."""

id: "Snowflake_Type" = attrs.field(
Expand All @@ -263,6 +263,11 @@ class ThreadMembersUpdate(BaseEvent):
removed_member_ids: List["Snowflake_Type"] = attrs.field(repr=False, factory=list)
"""Users removed from the thread"""

@property
def channel(self) -> Optional["TYPE_THREAD_CHANNEL"]:
"""The thread channel this event is dispatched from"""
return self.client.get_channel(self.id)


@attrs.define(eq=False, order=False, hash=False, kw_only=False)
class GuildJoin(GuildEvent):
Expand Down
1 change: 1 addition & 0 deletions interactions/api/events/processors/thread_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def _on_raw_thread_members_update(self, event: "RawGatewayEvent") -> None:
g_id = event.data.get("guild_id")
self.dispatch(
events.ThreadMembersUpdate(
g_id,
event.data.get("id"),
event.data.get("member_count"),
[await self.cache.fetch_member(g_id, m["user_id"]) for m in event.data.get("added_members", [])],
Expand Down

0 comments on commit 5c21875

Please sign in to comment.