Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
feat: add support for getting a threads message (#598)
Browse files Browse the repository at this point in the history
* feat: add support for getting a threads message

* refactor: use property not attribute
  • Loading branch information
LordOfPolls authored Aug 14, 2022
1 parent 7d23121 commit 6faa36b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions naff/models/discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,11 @@ def parent_channel(self) -> Union[GuildText, "GuildForum"]:
"""The channel this thread is a child of."""
return self._client.cache.get_channel(self.parent_id)

@property
def parent_message(self) -> Optional["Message"]:
"""The message this thread is a child of."""
return self._client.cache.get_message(self.parent_id, self.id)

@property
def mention(self) -> str:
"""Returns a string that would mention this thread."""
Expand Down
5 changes: 5 additions & 0 deletions naff/models/discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ async def mention_roles(self) -> AsyncGenerator["models.Role", None]:
for r_id in self._mention_roles:
yield await self._client.cache.fetch_role(self._guild_id, r_id)

@property
def thread(self) -> "models.TYPE_THREAD_CHANNEL":
"""The thread that was started from this message, if any"""
return self._client.cache.get_channel(self.id)

async def fetch_referenced_message(self) -> Optional["Message"]:
"""
Fetch the message this message is referencing, if any.
Expand Down

0 comments on commit 6faa36b

Please sign in to comment.