aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Nørgaard <[email protected]>2021-07-03 05:14:48 +0100
committerGitHub <[email protected]>2021-07-03 00:14:48 -0400
commitb7b75e2b1f4beb6d5764d1fce27b078000f6ad41 (patch)
treedd9f73c527f556691099f641e661931dbc62ac71
parentFix versionadded on ChannelType.private_thread (diff)
downloaddiscord.py-b7b75e2b1f4beb6d5764d1fce27b078000f6ad41.tar.xz
discord.py-b7b75e2b1f4beb6d5764d1fce27b078000f6ad41.zip
Add Thread.is_nsfw
-rw-r--r--discord/threads.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/discord/threads.py b/discord/threads.py
index d3fa453c..85a37018 100644
--- a/discord/threads.py
+++ b/discord/threads.py
@@ -268,6 +268,15 @@ class Thread(Messageable, Hashable):
"""
return self._type is ChannelType.news_thread
+ def is_nsfw(self) -> bool:
+ """:class:`bool`: Whether the thread is NSFW or not.
+
+ An NSFW thread is a thread that has a parent that is an NSFW channel,
+ i.e. :meth:`.TextChannel.is_nsfw` is ``True``.
+ """
+ parent = self.parent
+ return parent is not None and parent.is_nsfw()
+
def permissions_for(self, obj: Union[Member, Role], /) -> Permissions:
"""Handles permission resolution for the :class:`~discord.Member`
or :class:`~discord.Role`.