aboutsummaryrefslogtreecommitdiff
path: root/discord/threads.py
diff options
context:
space:
mode:
authorArthur <[email protected]>2021-07-31 03:27:10 +0200
committerGitHub <[email protected]>2021-07-30 21:27:10 -0400
commit8db79d2579e78de0441f887b71845d3d2a151203 (patch)
tree82eb11d73ae505a926010c6939b11dd6709962a2 /discord/threads.py
parent[commands] fix bot_has_role and is_nsfw for threads (diff)
downloaddiscord.py-8db79d2579e78de0441f887b71845d3d2a151203.tar.xz
discord.py-8db79d2579e78de0441f887b71845d3d2a151203.zip
Add Thread.category
Diffstat (limited to 'discord/threads.py')
-rw-r--r--discord/threads.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/discord/threads.py b/discord/threads.py
index 04b09610..7a6664b1 100644
--- a/discord/threads.py
+++ b/discord/threads.py
@@ -47,7 +47,7 @@ if TYPE_CHECKING:
ThreadArchiveDuration,
)
from .guild import Guild
- from .channel import TextChannel
+ from .channel import TextChannel, CategoryChannel
from .member import Member
from .message import Message, PartialMessage
from .abc import Snowflake, SnowflakeTime
@@ -239,6 +239,26 @@ class Thread(Messageable, Hashable):
return self._state._get_message(self.last_message_id) if self.last_message_id else None
@property
+ def category(self) -> Optional[CategoryChannel]:
+ """The category channel the parent channel belongs to, if applicable.
+
+ Raises
+ -------
+ ClientException
+ The parent channel was not cached and returned ``None``.
+
+ Returns
+ -------
+ Optional[:class:`CategoryChannel`]
+ The parent channel's category.
+ """
+
+ parent = self.parent
+ if parent is None:
+ raise ClientException('Parent channel not found')
+ return parent.category
+
+ @property
def category_id(self) -> Optional[int]:
"""The category channel ID the parent channel belongs to, if applicable.