Browse Source

Add Thread.category

pull/7313/head
Arthur 4 years ago
committed by GitHub
parent
commit
8db79d2579
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      discord/threads.py

22
discord/threads.py

@ -47,7 +47,7 @@ if TYPE_CHECKING:
ThreadArchiveDuration, ThreadArchiveDuration,
) )
from .guild import Guild from .guild import Guild
from .channel import TextChannel from .channel import TextChannel, CategoryChannel
from .member import Member from .member import Member
from .message import Message, PartialMessage from .message import Message, PartialMessage
from .abc import Snowflake, SnowflakeTime from .abc import Snowflake, SnowflakeTime
@ -238,6 +238,26 @@ class Thread(Messageable, Hashable):
""" """
return self._state._get_message(self.last_message_id) if self.last_message_id else None 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 @property
def category_id(self) -> Optional[int]: def category_id(self) -> Optional[int]:
"""The category channel ID the parent channel belongs to, if applicable. """The category channel ID the parent channel belongs to, if applicable.

Loading…
Cancel
Save