Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_nsfw to voice channels #1317

Merged
merged 3 commits into from
May 5, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
.. versionadded:: 2.0
"""

__slots__ = ()
__slots__ = ('nsfw')

def _update(self, guild: Guild, data: VoiceChannelPayload):
super()._update(guild, data)
self.nsfw: bool = data.get("nsfw", False)

def __repr__(self) -> str:
attrs = [
Expand All @@ -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.
Expand Down