From fa6fa6a5678dcd17dc148d81916d3a71a18a744c Mon Sep 17 00:00:00 2001 From: Lilly Rose Berner Date: Wed, 9 Jun 2021 14:21:45 +0200 Subject: [PATCH] Add category_id shortcut to Thread --- discord/threads.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/discord/threads.py b/discord/threads.py index b239006ca..8d22c742e 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.