Skip to content

Commit b0e0840

Browse files
LumabotsPaillat-dev
authored andcommitted
feat: adding missing parameters and attribute documentation (Pycord-Development#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]> (cherry picked from commit 9fd9b3e) Signed-off-by: Paillat-dev <[email protected]>
1 parent 90ba570 commit b0e0840

File tree

3 files changed

+210
-24
lines changed

3 files changed

+210
-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`.
@@ -182,6 +184,8 @@ These changes are available on the `master` branch, but have not yet been releas
182184
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
183185
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
184186
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
187+
- Deprecated `is_nsfw` for categories since it was never supported by the API.
188+
([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
185189
- Deprecated `Messageable.pins()` returning a list of `Message`; it should be used as an
186190
iterator of `MessagePin` instead.
187191
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))

discord/channel.py

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def __init__(
225225

226226
@property
227227
def _repr_attrs(self) -> tuple[str, ...]:
228-
return "id", "name", "position", "nsfw", "category_id"
228+
return "id", "name", "position", "category_id"
229229

230230
def __repr__(self) -> str:
231231
attrs = [(val, getattr(self, val)) for val in self._repr_attrs]
@@ -790,7 +790,7 @@ async def edit(self, *, reason=None, **options):
790790
position: :class:`int`
791791
The new channel's position.
792792
nsfw: :class:`bool`
793-
To mark the channel as NSFW or not.
793+
Whether the channel is marked as NSFW.
794794
sync_permissions: :class:`bool`
795795
Whether to sync permissions with the channel's new or pre-existing
796796
category. Defaults to ``False``.
@@ -1012,6 +1012,8 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
10121012
if self.default_sort_order is not None:
10131013
self.default_sort_order = try_enum(SortOrder, self.default_sort_order)
10141014

1015+
self.default_reaction_emoji = None
1016+
10151017
reaction_emoji_ctx: dict = data.get("default_reaction_emoji")
10161018
if reaction_emoji_ctx is not None:
10171019
emoji_name = reaction_emoji_ctx.get("emoji_name")
@@ -1086,7 +1088,7 @@ async def edit(self, *, reason=None, **options):
10861088
position: :class:`int`
10871089
The new channel's position.
10881090
nsfw: :class:`bool`
1089-
To mark the channel as NSFW or not.
1091+
Whether the channel is marked as NSFW.
10901092
sync_permissions: :class:`bool`
10911093
Whether to sync permissions with the channel's new or pre-existing
10921094
category. Defaults to ``False``.
@@ -1451,7 +1453,7 @@ async def edit(self, *, reason=None, **options):
14511453
position: :class:`int`
14521454
The new channel's position.
14531455
nsfw: :class:`bool`
1454-
To mark the channel as NSFW or not.
1456+
Whether the channel is marked as NSFW.
14551457
sync_permissions: :class:`bool`
14561458
Whether to sync permissions with the channel's new or pre-existing
14571459
category. Defaults to ``False``.
@@ -1691,6 +1693,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
16911693
Extra features of the channel.
16921694
16931695
.. versionadded:: 2.0
1696+
1697+
nsfw: :class:`bool`
1698+
Whether the channel is marked as NSFW.
1699+
1700+
.. versionadded:: 2.7
16941701
"""
16951702

16961703
def __init__(
@@ -1998,6 +2005,7 @@ async def edit(
19982005
rtc_region: VoiceRegion | None = ...,
19992006
video_quality_mode: VideoQualityMode = ...,
20002007
slowmode_delay: int = ...,
2008+
nsfw: bool = ...,
20012009
reason: str | None = ...,
20022010
) -> VoiceChannel | None: ...
20032011

@@ -2048,6 +2056,15 @@ async def edit(self, *, reason=None, **options):
20482056
20492057
.. versionadded:: 2.0
20502058
2059+
slowmode_delay: :class:`int`
2060+
Specifies the slowmode rate limit for user in this channel, in seconds.
2061+
A value of `0` disables slowmode. The maximum value possible is `21600`.
2062+
2063+
nsfw: :class:`bool`
2064+
Whether the channel is marked as NSFW.
2065+
2066+
.. versionadded:: 2.7
2067+
20512068
Returns
20522069
-------
20532070
Optional[:class:`.VoiceChannel`]
@@ -2202,6 +2219,15 @@ class StageChannel(discord.abc.Messageable, VocalGuildChannel):
22022219
last_message_id: Optional[:class:`int`]
22032220
The ID of the last message sent to this channel. It may not always point to an existing or valid message.
22042221
.. versionadded:: 2.5
2222+
2223+
slowmode_delay: :class:`int`
2224+
Specifies the slowmode rate limit for user in this channel, in seconds.
2225+
The maximum value possible is `21600`.
2226+
2227+
nsfw: :class:`bool`
2228+
Whether the channel is marked as NSFW.
2229+
2230+
.. versionadded:: 2.7
22052231
"""
22062232

22072233
__slots__ = ("topic",)
@@ -2661,6 +2687,16 @@ async def edit(self, *, reason=None, **options):
26612687
26622688
.. versionadded:: 2.0
26632689
2690+
bitrate: :class:`int`
2691+
The channel's preferred audio bitrate in bits per second.
2692+
2693+
user_limit: :class:`int`
2694+
The channel's limit for number of members that can be in a voice channel.
2695+
2696+
slowmode_delay: :class:`int`
2697+
Specifies the slowmode rate limit for user in this channel, in seconds.
2698+
A value of `0` disables slowmode. The maximum value possible is `21600`.
2699+
26642700
Returns
26652701
-------
26662702
Optional[:class:`.StageChannel`]
@@ -2717,12 +2753,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
27172753
position: Optional[:class:`int`]
27182754
The position in the category list. This is a number that starts at 0. e.g. the
27192755
top category is position 0. Can be ``None`` if the channel was received in an interaction.
2720-
nsfw: :class:`bool`
2721-
If the channel is marked as "not safe for work".
27222756
27232757
.. note::
27242758
2725-
To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
27262759
flags: :class:`ChannelFlags`
27272760
Extra features of the channel.
27282761
@@ -2733,7 +2766,6 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
27332766
"name",
27342767
"id",
27352768
"guild",
2736-
"nsfw",
27372769
"_state",
27382770
"position",
27392771
"_overwrites",
@@ -2747,7 +2779,9 @@ def __init__(self, *, state: ConnectionState, guild: Guild, data: CategoryChanne
27472779
self._update(guild, data)
27482780

27492781
def __repr__(self) -> str:
2750-
return f"<CategoryChannel id={self.id} name={self.name!r} position={self.position} nsfw={self.nsfw}>"
2782+
return (
2783+
f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}"
2784+
)
27512785

27522786
def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
27532787
# This data will always exist
@@ -2757,7 +2791,6 @@ def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
27572791

27582792
# This data may be missing depending on how this object is being created/updated
27592793
if not data.pop("_invoke_flag", False):
2760-
self.nsfw: bool = data.get("nsfw", False)
27612794
self.position: int = data.get("position")
27622795
self.flags: ChannelFlags = ChannelFlags._from_value(data.get("flags", 0))
27632796
self._fill_overwrites(data)
@@ -2771,21 +2804,16 @@ def type(self) -> ChannelType:
27712804
"""The channel's Discord type."""
27722805
return ChannelType.category
27732806

2774-
def is_nsfw(self) -> bool:
2775-
"""Checks if the category is NSFW."""
2776-
return self.nsfw
2777-
27782807
@copy_doc(discord.abc.GuildChannel.clone)
27792808
async def clone(self, *, name: str | None = None, reason: str | None = None) -> CategoryChannel:
2780-
return await self._clone_impl({"nsfw": self.nsfw}, name=name, reason=reason)
2809+
return await self._clone_impl({}, name=name, reason=reason)
27812810

27822811
@overload
27832812
async def edit(
27842813
self,
27852814
*,
27862815
name: str = ...,
27872816
position: int = ...,
2788-
nsfw: bool = ...,
27892817
overwrites: Mapping[Role | Member, PermissionOverwrite] = ...,
27902818
reason: str | None = ...,
27912819
) -> CategoryChannel | None: ...
@@ -2813,8 +2841,6 @@ async def edit(self, *, reason=None, **options):
28132841
The new category's name.
28142842
position: :class:`int`
28152843
The new category's position.
2816-
nsfw: :class:`bool`
2817-
To mark the category as NSFW or not.
28182844
reason: Optional[:class:`str`]
28192845
The reason for editing this category. Shows up on the audit log.
28202846
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
@@ -2946,6 +2972,25 @@ async def create_forum_channel(self, name: str, **options: Any) -> ForumChannel:
29462972
"""
29472973
return await self.guild.create_forum_channel(name, category=self, **options)
29482974

2975+
@utils.deprecated(
2976+
since="2.7",
2977+
removed="3.0",
2978+
reference="NSFW categories are not available in the Discord API.",
2979+
)
2980+
def is_nsfw(self) -> bool:
2981+
return False
2982+
2983+
# TODO: Remove in 3.0
2984+
2985+
@property
2986+
@utils.deprecated(
2987+
since="2.7",
2988+
removed="3.0",
2989+
reference="NSFW categories are not available in the Discord API.",
2990+
)
2991+
def nsfw(self) -> bool:
2992+
return False
2993+
29492994

29502995
DMC = TypeVar("DMC", bound="DMChannel")
29512996

0 commit comments

Comments
 (0)