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

feat: add support for getting a threads message #598

Merged
merged 2 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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