Skip to content

Commit

Permalink
Add cache channel to reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexFlipnote committed Dec 14, 2024
1 parent 78df5f6 commit 5230202
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions discord_http/gateway/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,28 @@ def guild(self) -> "Guild | PartialGuild | None":

@property
def channel(self) -> "PartialChannel | None":
""" `PartialChannel` | `None`: Returns the channel the message was sent in """
"""
`BaseChannel | PartialChannel`: Returns the channel the message was sent in.
If guild and channel cache is enabled, it can also return full channel object.
"""
if not self.channel_id:
return None

if self.guild_id:
cache = self._state.cache.get_channel_thread(
guild_id=self.guild_id,
channel_id=self.channel_id
)

if cache:
return cache

from ..channel import PartialChannel
return PartialChannel(state=self._state, id=self.channel_id)
return PartialChannel(
state=self._state,
id=self.channel_id,
guild_id=self.guild_id
)

@property
def message(self) -> "PartialMessage | None":
Expand Down

0 comments on commit 5230202

Please sign in to comment.