mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-08-18 09:00:48 +00:00
Add proper nsfw support for vocal guild channels
This commit is contained in:
parent
3378435bf0
commit
3ef8f77e81
@ -130,11 +130,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
|||||||
Bots and users with :attr:`~Permissions.manage_channels` or
|
Bots and users with :attr:`~Permissions.manage_channels` or
|
||||||
:attr:`~Permissions.manage_messages` bypass slowmode.
|
:attr:`~Permissions.manage_messages` bypass slowmode.
|
||||||
nsfw: :class:`bool`
|
nsfw: :class:`bool`
|
||||||
If the channel is marked as "not safe for work".
|
If the channel is marked as "not safe for work" or "age restricted".
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
|
|
||||||
default_auto_archive_duration: :class:`int`
|
default_auto_archive_duration: :class:`int`
|
||||||
The default auto archive duration in minutes for threads created in this channel.
|
The default auto archive duration in minutes for threads created in this channel.
|
||||||
|
|
||||||
@ -843,6 +839,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha
|
|||||||
'name',
|
'name',
|
||||||
'id',
|
'id',
|
||||||
'guild',
|
'guild',
|
||||||
|
'nsfw',
|
||||||
'bitrate',
|
'bitrate',
|
||||||
'user_limit',
|
'user_limit',
|
||||||
'_state',
|
'_state',
|
||||||
@ -868,6 +865,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha
|
|||||||
def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPayload]) -> None:
|
def _update(self, guild: Guild, data: Union[VoiceChannelPayload, StageChannelPayload]) -> None:
|
||||||
self.guild: Guild = guild
|
self.guild: Guild = guild
|
||||||
self.name: str = data['name']
|
self.name: str = data['name']
|
||||||
|
self.nsfw: bool = data.get('nsfw', False)
|
||||||
self.rtc_region: Optional[str] = data.get('rtc_region')
|
self.rtc_region: Optional[str] = data.get('rtc_region')
|
||||||
self.video_quality_mode: VideoQualityMode = try_enum(VideoQualityMode, data.get('video_quality_mode', 1))
|
self.video_quality_mode: VideoQualityMode = try_enum(VideoQualityMode, data.get('video_quality_mode', 1))
|
||||||
self.category_id: Optional[int] = utils._get_as_snowflake(data, 'parent_id')
|
self.category_id: Optional[int] = utils._get_as_snowflake(data, 'parent_id')
|
||||||
@ -881,6 +879,13 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha
|
|||||||
def _sorting_bucket(self) -> int:
|
def _sorting_bucket(self) -> int:
|
||||||
return ChannelType.voice.value
|
return ChannelType.voice.value
|
||||||
|
|
||||||
|
def is_nsfw(self) -> bool:
|
||||||
|
""":class:`bool`: Checks if the channel is NSFW.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
"""
|
||||||
|
return self.nsfw
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def members(self) -> List[Member]:
|
def members(self) -> List[Member]:
|
||||||
"""List[:class:`Member`]: Returns all members that are currently inside this voice channel."""
|
"""List[:class:`Member`]: Returns all members that are currently inside this voice channel."""
|
||||||
@ -966,6 +971,10 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
|
|||||||
The guild the channel belongs to.
|
The guild the channel belongs to.
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
The channel ID.
|
The channel ID.
|
||||||
|
nsfw: :class:`bool`
|
||||||
|
If the channel is marked as "not safe for work" or "age restricted".
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
category_id: Optional[:class:`int`]
|
category_id: Optional[:class:`int`]
|
||||||
The category channel ID this channel belongs to, if applicable.
|
The category channel ID this channel belongs to, if applicable.
|
||||||
position: :class:`int`
|
position: :class:`int`
|
||||||
@ -1275,6 +1284,7 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
name: str = ...,
|
name: str = ...,
|
||||||
|
nsfw: bool = ...,
|
||||||
bitrate: int = ...,
|
bitrate: int = ...,
|
||||||
user_limit: int = ...,
|
user_limit: int = ...,
|
||||||
position: int = ...,
|
position: int = ...,
|
||||||
@ -1318,6 +1328,8 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
|
|||||||
The new channel's name.
|
The new channel's name.
|
||||||
bitrate: :class:`int`
|
bitrate: :class:`int`
|
||||||
The new channel's bitrate.
|
The new channel's bitrate.
|
||||||
|
nsfw: :class:`bool`
|
||||||
|
To mark the channel as NSFW or not.
|
||||||
user_limit: :class:`int`
|
user_limit: :class:`int`
|
||||||
The new channel's user limit.
|
The new channel's user limit.
|
||||||
position: :class:`int`
|
position: :class:`int`
|
||||||
@ -1396,6 +1408,10 @@ class StageChannel(VocalGuildChannel):
|
|||||||
The guild the channel belongs to.
|
The guild the channel belongs to.
|
||||||
id: :class:`int`
|
id: :class:`int`
|
||||||
The channel ID.
|
The channel ID.
|
||||||
|
nsfw: :class:`bool`
|
||||||
|
If the channel is marked as "not safe for work" or "age restricted".
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
topic: Optional[:class:`str`]
|
topic: Optional[:class:`str`]
|
||||||
The channel's topic. ``None`` if it isn't set.
|
The channel's topic. ``None`` if it isn't set.
|
||||||
category_id: Optional[:class:`int`]
|
category_id: Optional[:class:`int`]
|
||||||
@ -1562,6 +1578,7 @@ class StageChannel(VocalGuildChannel):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
name: str = ...,
|
name: str = ...,
|
||||||
|
nsfw: bool = ...,
|
||||||
position: int = ...,
|
position: int = ...,
|
||||||
sync_permissions: int = ...,
|
sync_permissions: int = ...,
|
||||||
category: Optional[CategoryChannel] = ...,
|
category: Optional[CategoryChannel] = ...,
|
||||||
@ -1603,6 +1620,8 @@ class StageChannel(VocalGuildChannel):
|
|||||||
The new channel's name.
|
The new channel's name.
|
||||||
position: :class:`int`
|
position: :class:`int`
|
||||||
The new channel's position.
|
The new channel's position.
|
||||||
|
nsfw: :class:`bool`
|
||||||
|
To mark the channel as NSFW or not.
|
||||||
sync_permissions: :class:`bool`
|
sync_permissions: :class:`bool`
|
||||||
Whether to sync permissions with the channel's new or pre-existing
|
Whether to sync permissions with the channel's new or pre-existing
|
||||||
category. Defaults to ``False``.
|
category. Defaults to ``False``.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user