aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLilly Rose Berner <[email protected]>2021-06-09 14:21:45 +0200
committerGitHub <[email protected]>2021-06-09 08:21:45 -0400
commitfa6fa6a5678dcd17dc148d81916d3a71a18a744c (patch)
tree51cebb380feb41fb30a159d3b51357fc774dad6f
parentAdd __str__ method to Thread (diff)
downloaddiscord.py-fa6fa6a5678dcd17dc148d81916d3a71a18a744c.tar.xz
discord.py-fa6fa6a5678dcd17dc148d81916d3a71a18a744c.zip
Add category_id shortcut to Thread
-rw-r--r--discord/threads.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/discord/threads.py b/discord/threads.py
index b239006c..8d22c742 100644
--- a/discord/threads.py
+++ b/discord/threads.py
@@ -223,6 +223,26 @@ class Thread(Messageable, Hashable):
"""
return self._state._get_message(self.last_message_id) if self.last_message_id else None
+ @property
+ def category_id(self) -> Optional[int]:
+ """The category channel ID the parent channel belongs to, if applicable.
+
+ Raises
+ -------
+ ClientException
+ The parent channel was not cached and returned ``None``.
+
+ Returns
+ -------
+ Optional[:class:`int`]
+ The parent channel's category ID.
+ """
+
+ parent = self.parent
+ if parent is None:
+ raise ClientException('Parent channel not found')
+ return parent.category_id
+
def is_private(self) -> bool:
""":class:`bool`: Whether the thread is a private thread.