Skip to content

Commit 9fd9b3e

Browse files
Lumabotspre-commit-ci[bot]plun1331JustaSqu1dDorukyum
authored
feat: adding missing parameters and attribute documentation (#2772)
* Update guild.py Signed-off-by: Lumabots <[email protected]> * Update channel.py add missings docs Signed-off-by: Lumabots <[email protected]> * Update guild.py Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update channel.py Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update guild.py Signed-off-by: Lumabots <[email protected]> * Update guild.py Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * Update guild.py Signed-off-by: Lumabots <[email protected]> * Update channel.py removal of all the nsfw mention which should not exist for category Signed-off-by: Lumabots <[email protected]> * Update channel.py Signed-off-by: Lumabots <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * fix typo Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/channel.py Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/channel.py Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/channel.py Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]> * style(pre-commit): auto fixes from pre-commit.com hooks * feat(channel): deprecate is_nsfw method in CategoryChannel * fix(channel): correct deprecated decorator arguments in CategoryChannel * style(pre-commit): auto fixes from pre-commit.com hooks * fix: improve clarity of NSFW parameter documentation and slowmode for continiuty * fix: improve clarity of NSFW parameter documentation * fix: add missing parameters to channel creation methods and deprecate unsupported nsfw for categories * Update CHANGELOG.md Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * fix: add missing parameters for channel creation and allow default_reaction_emoji to be None * Update CHANGELOG.md Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update CHANGELOG.md Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update CHANGELOG.md Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * added reference * deprecated nsfw using property * Update channel.py * Update channel.py * Update discord/guild.py Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/guild.py Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/guild.py Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lumouille <[email protected]> * Update discord/channel.py Signed-off-by: Lumouille <[email protected]> --------- Signed-off-by: Lumabots <[email protected]> Signed-off-by: Lumouille <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: plun1331 <[email protected]> Co-authored-by: JustaSqu1d <[email protected]> Co-authored-by: Dorukyum <[email protected]>
1 parent 54884c3 commit 9fd9b3e

File tree

3 files changed

+205
-24
lines changed

3 files changed

+205
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ These changes are available on the `master` branch, but have not yet been releas
5757
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
5858
- Added the ability to pass a `datetime.time` object to `format_dt`.
5959
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
60+
- Added various missing channel parameters and allow `default_reaction_emoji` to be
61+
`None`. ([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
6062
- Added support for type hinting slash command options with `typing.Annotated`.
6163
([#2782](https://github.com/Pycord-Development/pycord/pull/2782))
6264
- Added conversion to `Member` in `MentionableConverter`.
@@ -186,6 +188,8 @@ These changes are available on the `master` branch, but have not yet been releas
186188
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
187189
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
188190
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
191+
- Deprecated `is_nsfw` for categories since it was never supported by the API.
192+
([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
189193
- Deprecated `Messageable.pins()` returning a list of `Message`; it should be used as an
190194
iterator of `MessagePin` instead.
191195
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))

discord/channel.py

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def __init__(
232232

233233
@property
234234
def _repr_attrs(self) -> tuple[str, ...]:
235-
return "id", "name", "position", "nsfw", "category_id"
235+
return "id", "name", "position", "category_id"
236236

237237
def __repr__(self) -> str:
238238
attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
@@ -828,7 +828,7 @@ async def edit(self, *, reason=None, **options):
828828
position: :class:`int`
829829
The new channel's position.
830830
nsfw: :class:`bool`
831-
To mark the channel as NSFW or not.
831+
Whether the channel is marked as NSFW.
832832
sync_permissions: :class:`bool`
833833
Whether to sync permissions with the channel's new or pre-existing
834834
category. Defaults to ``False``.
@@ -1055,6 +1055,8 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
10551055
if self.default_sort_order is not None:
10561056
self.default_sort_order = try_enum(SortOrder, self.default_sort_order)
10571057

1058+
self.default_reaction_emoji = None
1059+
10581060
reaction_emoji_ctx: dict = data.get("default_reaction_emoji")
10591061
if reaction_emoji_ctx is not None:
10601062
emoji_name = reaction_emoji_ctx.get("emoji_name")
@@ -1131,7 +1133,7 @@ async def edit(self, *, reason=None, **options):
11311133
position: :class:`int`
11321134
The new channel's position.
11331135
nsfw: :class:`bool`
1134-
To mark the channel as NSFW or not.
1136+
Whether the channel is marked as NSFW.
11351137
sync_permissions: :class:`bool`
11361138
Whether to sync permissions with the channel's new or pre-existing
11371139
category. Defaults to ``False``.
@@ -1509,7 +1511,7 @@ async def edit(self, *, reason=None, **options):
15091511
position: :class:`int`
15101512
The new channel's position.
15111513
nsfw: :class:`bool`
1512-
To mark the channel as NSFW or not.
1514+
Whether the channel is marked as NSFW.
15131515
sync_permissions: :class:`bool`
15141516
Whether to sync permissions with the channel's new or pre-existing
15151517
category. Defaults to ``False``.
@@ -1757,6 +1759,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
17571759
Extra features of the channel.
17581760
17591761
.. versionadded:: 2.0
1762+
1763+
nsfw: :class:`bool`
1764+
Whether the channel is marked as NSFW.
1765+
1766+
.. versionadded:: 2.7
17601767
"""
17611768

17621769
def __init__(
@@ -2075,6 +2082,7 @@ async def edit(
20752082
rtc_region: VoiceRegion | None = ...,
20762083
video_quality_mode: VideoQualityMode = ...,
20772084
slowmode_delay: int = ...,
2085+
nsfw: bool = ...,
20782086
reason: str | None = ...,
20792087
) -> VoiceChannel | None: ...
20802088

@@ -2125,6 +2133,15 @@ async def edit(self, *, reason=None, **options):
21252133
21262134
.. versionadded:: 2.0
21272135
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+
21282145
Returns
21292146
-------
21302147
Optional[:class:`.VoiceChannel`]
@@ -2283,6 +2300,15 @@ class StageChannel(discord.abc.Messageable, VocalGuildChannel):
22832300
last_message_id: Optional[:class:`int`]
22842301
The ID of the last message sent to this channel. It may not always point to an existing or valid message.
22852302
.. 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
22862312
"""
22872313

22882314
__slots__ = ("topic",)
@@ -2767,6 +2793,16 @@ async def edit(self, *, reason=None, **options):
27672793
27682794
.. versionadded:: 2.0
27692795
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+
27702806
Returns
27712807
-------
27722808
Optional[:class:`.StageChannel`]
@@ -2823,12 +2859,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
28232859
position: Optional[:class:`int`]
28242860
The position in the category list. This is a number that starts at 0. e.g. the
28252861
top category is position 0. Can be ``None`` if the channel was received in an interaction.
2826-
nsfw: :class:`bool`
2827-
If the channel is marked as "not safe for work".
28282862
28292863
.. note::
28302864
2831-
To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
28322865
flags: :class:`ChannelFlags`
28332866
Extra features of the channel.
28342867
@@ -2839,7 +2872,6 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
28392872
"name",
28402873
"id",
28412874
"guild",
2842-
"nsfw",
28432875
"_state",
28442876
"position",
28452877
"_overwrites",
@@ -2856,8 +2888,7 @@ def __init__(
28562888

28572889
def __repr__(self) -> str:
28582890
return (
2859-
"<CategoryChannel"
2860-
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}"
28612892
)
28622893

28632894
def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
@@ -2868,7 +2899,6 @@ def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
28682899

28692900
# This data may be missing depending on how this object is being created/updated
28702901
if not data.pop("_invoke_flag", False):
2871-
self.nsfw: bool = data.get("nsfw", False)
28722902
self.position: int = data.get("position")
28732903
self.flags: ChannelFlags = ChannelFlags._from_value(data.get("flags", 0))
28742904
self._fill_overwrites(data)
@@ -2882,23 +2912,18 @@ def type(self) -> ChannelType:
28822912
"""The channel's Discord type."""
28832913
return ChannelType.category
28842914

2885-
def is_nsfw(self) -> bool:
2886-
"""Checks if the category is NSFW."""
2887-
return self.nsfw
2888-
28892915
@utils.copy_doc(discord.abc.GuildChannel.clone)
28902916
async def clone(
28912917
self, *, name: str | None = None, reason: str | None = None
28922918
) -> CategoryChannel:
2893-
return await self._clone_impl({"nsfw": self.nsfw}, name=name, reason=reason)
2919+
return await self._clone_impl({}, name=name, reason=reason)
28942920

28952921
@overload
28962922
async def edit(
28972923
self,
28982924
*,
28992925
name: str = ...,
29002926
position: int = ...,
2901-
nsfw: bool = ...,
29022927
overwrites: Mapping[Role | Member, PermissionOverwrite] = ...,
29032928
reason: str | None = ...,
29042929
) -> CategoryChannel | None: ...
@@ -2926,8 +2951,6 @@ async def edit(self, *, reason=None, **options):
29262951
The new category's name.
29272952
position: :class:`int`
29282953
The new category's position.
2929-
nsfw: :class:`bool`
2930-
To mark the category as NSFW or not.
29312954
reason: Optional[:class:`str`]
29322955
The reason for editing this category. Shows up on the audit log.
29332956
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
@@ -3075,6 +3098,25 @@ async def create_forum_channel(self, name: str, **options: Any) -> ForumChannel:
30753098
"""
30763099
return await self.guild.create_forum_channel(name, category=self, **options)
30773100

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+
30783120

30793121
DMC = TypeVar("DMC", bound="DMChannel")
30803122

0 commit comments

Comments
 (0)