48
48
InviteTarget ,
49
49
SortOrder ,
50
50
StagePrivacyLevel ,
51
+ )
52
+ from .enums import ThreadArchiveDuration as ThreadArchiveDurationEnum
53
+ from .enums import (
51
54
VideoQualityMode ,
52
55
VoiceRegion ,
53
56
try_enum ,
@@ -229,7 +232,7 @@ def __init__(
229
232
230
233
@property
231
234
def _repr_attrs (self ) -> tuple [str , ...]:
232
- return "id" , "name" , "position" , "nsfw" , " category_id"
235
+ return "id" , "name" , "position" , "category_id"
233
236
234
237
def __repr__ (self ) -> str :
235
238
attrs = [(val , getattr (self , val )) for val in self ._repr_attrs ]
@@ -825,7 +828,7 @@ async def edit(self, *, reason=None, **options):
825
828
position: :class:`int`
826
829
The new channel's position.
827
830
nsfw: :class:`bool`
828
- To mark the channel as NSFW or not .
831
+ Whether the channel is marked as NSFW .
829
832
sync_permissions: :class:`bool`
830
833
Whether to sync permissions with the channel's new or pre-existing
831
834
category. Defaults to ``False``.
@@ -1052,6 +1055,8 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
1052
1055
if self .default_sort_order is not None :
1053
1056
self .default_sort_order = try_enum (SortOrder , self .default_sort_order )
1054
1057
1058
+ self .default_reaction_emoji = None
1059
+
1055
1060
reaction_emoji_ctx : dict = data .get ("default_reaction_emoji" )
1056
1061
if reaction_emoji_ctx is not None :
1057
1062
emoji_name = reaction_emoji_ctx .get ("emoji_name" )
@@ -1097,7 +1102,9 @@ async def edit(
1097
1102
sync_permissions : bool = ...,
1098
1103
category : CategoryChannel | None = ...,
1099
1104
slowmode_delay : int = ...,
1100
- default_auto_archive_duration : ThreadArchiveDuration = ...,
1105
+ default_auto_archive_duration : (
1106
+ ThreadArchiveDuration | ThreadArchiveDurationEnum
1107
+ ) = ...,
1101
1108
default_thread_slowmode_delay : int = ...,
1102
1109
default_sort_order : SortOrder = ...,
1103
1110
default_reaction_emoji : GuildEmoji | int | str | None = ...,
@@ -1126,7 +1133,7 @@ async def edit(self, *, reason=None, **options):
1126
1133
position: :class:`int`
1127
1134
The new channel's position.
1128
1135
nsfw: :class:`bool`
1129
- To mark the channel as NSFW or not .
1136
+ Whether the channel is marked as NSFW .
1130
1137
sync_permissions: :class:`bool`
1131
1138
Whether to sync permissions with the channel's new or pre-existing
1132
1139
category. Defaults to ``False``.
@@ -1143,6 +1150,7 @@ async def edit(self, *, reason=None, **options):
1143
1150
default_auto_archive_duration: :class:`int`
1144
1151
The new default auto archive duration in minutes for threads created in this channel.
1145
1152
Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
1153
+ :class:`ThreadArchiveDuration` can be used alternatively.
1146
1154
default_thread_slowmode_delay: :class:`int`
1147
1155
The new default slowmode delay in seconds for threads created in this channel.
1148
1156
@@ -1503,7 +1511,7 @@ async def edit(self, *, reason=None, **options):
1503
1511
position: :class:`int`
1504
1512
The new channel's position.
1505
1513
nsfw: :class:`bool`
1506
- To mark the channel as NSFW or not .
1514
+ Whether the channel is marked as NSFW .
1507
1515
sync_permissions: :class:`bool`
1508
1516
Whether to sync permissions with the channel's new or pre-existing
1509
1517
category. Defaults to ``False``.
@@ -1751,6 +1759,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
1751
1759
Extra features of the channel.
1752
1760
1753
1761
.. versionadded:: 2.0
1762
+
1763
+ nsfw: :class:`bool`
1764
+ Whether the channel is marked as NSFW.
1765
+
1766
+ .. versionadded:: 2.7
1754
1767
"""
1755
1768
1756
1769
def __init__ (
@@ -2069,6 +2082,7 @@ async def edit(
2069
2082
rtc_region : VoiceRegion | None = ...,
2070
2083
video_quality_mode : VideoQualityMode = ...,
2071
2084
slowmode_delay : int = ...,
2085
+ nsfw : bool = ...,
2072
2086
reason : str | None = ...,
2073
2087
) -> VoiceChannel | None : ...
2074
2088
@@ -2119,6 +2133,15 @@ async def edit(self, *, reason=None, **options):
2119
2133
2120
2134
.. versionadded:: 2.0
2121
2135
2136
+ slowmode_delay: :class:`int`
2137
+ Specifies the slowmode rate limit for user in this channel, in seconds.
2138
+ A value of `0` disables slowmode. The maximum value possible is `21600`.
2139
+
2140
+ nsfw: :class:`bool`
2141
+ Whether the channel is marked as NSFW.
2142
+
2143
+ .. versionadded:: 2.7
2144
+
2122
2145
Returns
2123
2146
-------
2124
2147
Optional[:class:`.VoiceChannel`]
@@ -2277,6 +2300,15 @@ class StageChannel(discord.abc.Messageable, VocalGuildChannel):
2277
2300
last_message_id: Optional[:class:`int`]
2278
2301
The ID of the last message sent to this channel. It may not always point to an existing or valid message.
2279
2302
.. versionadded:: 2.5
2303
+
2304
+ slowmode_delay: :class:`int`
2305
+ Specifies the slowmode rate limit for user in this channel, in seconds.
2306
+ The maximum value possible is `21600`.
2307
+
2308
+ nsfw: :class:`bool`
2309
+ Whether the channel is marked as NSFW.
2310
+
2311
+ .. versionadded:: 2.7
2280
2312
"""
2281
2313
2282
2314
__slots__ = ("topic" ,)
@@ -2761,6 +2793,16 @@ async def edit(self, *, reason=None, **options):
2761
2793
2762
2794
.. versionadded:: 2.0
2763
2795
2796
+ bitrate: :class:`int`
2797
+ The channel's preferred audio bitrate in bits per second.
2798
+
2799
+ user_limit: :class:`int`
2800
+ The channel's limit for number of members that can be in a voice channel.
2801
+
2802
+ slowmode_delay: :class:`int`
2803
+ Specifies the slowmode rate limit for user in this channel, in seconds.
2804
+ A value of `0` disables slowmode. The maximum value possible is `21600`.
2805
+
2764
2806
Returns
2765
2807
-------
2766
2808
Optional[:class:`.StageChannel`]
@@ -2817,12 +2859,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
2817
2859
position: Optional[:class:`int`]
2818
2860
The position in the category list. This is a number that starts at 0. e.g. the
2819
2861
top category is position 0. Can be ``None`` if the channel was received in an interaction.
2820
- nsfw: :class:`bool`
2821
- If the channel is marked as "not safe for work".
2822
2862
2823
2863
.. note::
2824
2864
2825
- To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
2826
2865
flags: :class:`ChannelFlags`
2827
2866
Extra features of the channel.
2828
2867
@@ -2833,7 +2872,6 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
2833
2872
"name" ,
2834
2873
"id" ,
2835
2874
"guild" ,
2836
- "nsfw" ,
2837
2875
"_state" ,
2838
2876
"position" ,
2839
2877
"_overwrites" ,
@@ -2850,8 +2888,7 @@ def __init__(
2850
2888
2851
2889
def __repr__ (self ) -> str :
2852
2890
return (
2853
- "<CategoryChannel"
2854
- f" id={ self .id } name={ self .name !r} position={ self .position } nsfw={ self .nsfw } >"
2891
+ f"<CategoryChannel id={ self .id } name={ self .name !r} position={ self .position } "
2855
2892
)
2856
2893
2857
2894
def _update (self , guild : Guild , data : CategoryChannelPayload ) -> None :
@@ -2862,7 +2899,6 @@ def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
2862
2899
2863
2900
# This data may be missing depending on how this object is being created/updated
2864
2901
if not data .pop ("_invoke_flag" , False ):
2865
- self .nsfw : bool = data .get ("nsfw" , False )
2866
2902
self .position : int = data .get ("position" )
2867
2903
self .flags : ChannelFlags = ChannelFlags ._from_value (data .get ("flags" , 0 ))
2868
2904
self ._fill_overwrites (data )
@@ -2876,23 +2912,18 @@ def type(self) -> ChannelType:
2876
2912
"""The channel's Discord type."""
2877
2913
return ChannelType .category
2878
2914
2879
- def is_nsfw (self ) -> bool :
2880
- """Checks if the category is NSFW."""
2881
- return self .nsfw
2882
-
2883
2915
@utils .copy_doc (discord .abc .GuildChannel .clone )
2884
2916
async def clone (
2885
2917
self , * , name : str | None = None , reason : str | None = None
2886
2918
) -> CategoryChannel :
2887
- return await self ._clone_impl ({"nsfw" : self . nsfw }, name = name , reason = reason )
2919
+ return await self ._clone_impl ({}, name = name , reason = reason )
2888
2920
2889
2921
@overload
2890
2922
async def edit (
2891
2923
self ,
2892
2924
* ,
2893
2925
name : str = ...,
2894
2926
position : int = ...,
2895
- nsfw : bool = ...,
2896
2927
overwrites : Mapping [Role | Member , PermissionOverwrite ] = ...,
2897
2928
reason : str | None = ...,
2898
2929
) -> CategoryChannel | None : ...
@@ -2920,8 +2951,6 @@ async def edit(self, *, reason=None, **options):
2920
2951
The new category's name.
2921
2952
position: :class:`int`
2922
2953
The new category's position.
2923
- nsfw: :class:`bool`
2924
- To mark the category as NSFW or not.
2925
2954
reason: Optional[:class:`str`]
2926
2955
The reason for editing this category. Shows up on the audit log.
2927
2956
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
@@ -3069,6 +3098,25 @@ async def create_forum_channel(self, name: str, **options: Any) -> ForumChannel:
3069
3098
"""
3070
3099
return await self .guild .create_forum_channel (name , category = self , ** options )
3071
3100
3101
+ @utils .deprecated (
3102
+ since = "2.7" ,
3103
+ removed = "3.0" ,
3104
+ reference = "NSFW categories are not available in the Discord API." ,
3105
+ )
3106
+ def is_nsfw (self ) -> bool :
3107
+ return False
3108
+
3109
+ # TODO: Remove in 3.0
3110
+
3111
+ @property
3112
+ @utils .deprecated (
3113
+ since = "2.7" ,
3114
+ removed = "3.0" ,
3115
+ reference = "NSFW categories are not available in the Discord API." ,
3116
+ )
3117
+ def nsfw (self ) -> bool :
3118
+ return False
3119
+
3072
3120
3073
3121
DMC = TypeVar ("DMC" , bound = "DMChannel" )
3074
3122
0 commit comments