From e391a8f9a62b1d92e81ab0b915ebfe0c7619f90a Mon Sep 17 00:00:00 2001 From: Middledot Date: Tue, 3 May 2022 17:26:39 -0400 Subject: [PATCH 1/2] Add is_nsfw to voice channels --- discord/channel.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/discord/channel.py b/discord/channel.py index 67ce857661..e55a094ca2 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -923,7 +923,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel): .. versionadded:: 2.0 """ - __slots__ = () + __slots__ = ('nsfw') + + def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPayload]): + super()._update(guild, data) + self.nsfw: bool = data.get("nsfw", False) def __repr__(self) -> str: attrs = [ @@ -942,6 +946,10 @@ def __repr__(self) -> str: async def _get_channel(self): return self + def is_nsfw(self) -> bool: + """:class:`bool`: Checks if the channel is NSFW.""" + return self.nsfw + @property def last_message(self) -> Optional[Message]: """Fetches the last message from this channel in cache. From 86ca920575491a55308531fc2d0779daaed6ee96 Mon Sep 17 00:00:00 2001 From: Middledot Date: Tue, 3 May 2022 17:27:55 -0400 Subject: [PATCH 2/2] fix typing --- discord/channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/channel.py b/discord/channel.py index e55a094ca2..776da84709 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -925,7 +925,7 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel): __slots__ = ('nsfw') - def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPayload]): + def _update(self, guild: Guild, data: VoiceChannelPayload): super()._update(guild, data) self.nsfw: bool = data.get("nsfw", False)