Skip to content

feat: adding missing parameters and attribute documentation #2772

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

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
426bb6a
Update guild.py
Lumabots Mar 29, 2025
6e68b7a
Update channel.py
Lumabots Mar 29, 2025
46aa608
Update guild.py
Lumabots Mar 29, 2025
332e652
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2025
eff4e52
Update channel.py
Lumabots Mar 29, 2025
477407f
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2025
e717f67
Update guild.py
Lumabots Mar 29, 2025
13c6037
Update guild.py
Lumabots Mar 29, 2025
c4b7091
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2025
1d7eb3f
Update CHANGELOG.md
Lumabots Mar 29, 2025
dd0f397
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 29, 2025
340cec3
Update CHANGELOG.md
Lumabots Apr 7, 2025
bc2fef9
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 7, 2025
d8b79ff
Update guild.py
Lumabots Apr 10, 2025
952aab8
Update channel.py
Lumabots Apr 10, 2025
7dd8a7a
Update channel.py
Lumabots Apr 10, 2025
0035a73
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2025
1ef8618
Merge branch 'master' into channel
Lumabots Apr 30, 2025
757ef9c
fix typo
Lumabots May 1, 2025
cab128e
Update discord/channel.py
Lumabots May 1, 2025
19a83f3
Update discord/channel.py
Lumabots May 1, 2025
913cf87
Update discord/channel.py
Lumabots May 1, 2025
121ae58
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 1, 2025
966b528
feat(channel): deprecate is_nsfw method in CategoryChannel
Lumabots May 9, 2025
691a27c
fix(channel): correct deprecated decorator arguments in CategoryChannel
Lumabots May 9, 2025
45c0f8b
Merge branch 'master' into channel
Lumabots May 9, 2025
e3e2bec
Merge branch 'master' into channel
Lumabots May 22, 2025
ca6a4bf
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2025
c83643f
Merge branch 'master' into channel
Lumabots Jun 17, 2025
c391c30
fix: improve clarity of NSFW parameter documentation and slowmode for…
Lumabots Jun 18, 2025
d401df9
fix: improve clarity of NSFW parameter documentation
Lumabots Jun 18, 2025
62879fb
fix: add missing parameters to channel creation methods and deprecate…
Lumabots Jun 19, 2025
469a4e2
Update CHANGELOG.md
Lumabots Jun 20, 2025
f0878b0
fix: add missing parameters for channel creation and allow default_re…
Lumabots Jun 20, 2025
87440ed
Merge branch 'master' into channel
Lumabots Jun 20, 2025
4b7ca07
Update CHANGELOG.md
Lumabots Jun 20, 2025
4d35fee
Update CHANGELOG.md
Lumabots Jun 20, 2025
d1f1602
Update CHANGELOG.md
Lumabots Jun 20, 2025
6c8b79e
Merge branch 'master' into channel
Lumabots Jun 20, 2025
7970680
added reference
Lumabots Jun 20, 2025
f073663
Merge branch 'channel' of https://github.com/Lumabots/pycord into cha…
Lumabots Jun 20, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
- Added the ability to pass a `datetime.time` object to `format_dt`.
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
- Added various missing channel parameters and allow `default_reaction_emoji` to be
`None`. ([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
- Added `discord.Interaction.created_at`.
([#2801](https://github.com/Pycord-Development/pycord/pull/2801))

Expand Down Expand Up @@ -147,6 +149,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
- Deprecated `is_nsfw` for categories since it was never supported by the API.
([#2772](https://github.com/Pycord-Development/pycord/pull/2772))

### Removed

Expand Down
69 changes: 52 additions & 17 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ async def edit(self, *, reason=None, **options):
position: :class:`int`
The new channel's position.
nsfw: :class:`bool`
To mark the channel as NSFW or not.
Whether the channel is marked as NSFW.
sync_permissions: :class:`bool`
Whether to sync permissions with the channel's new or pre-existing
category. Defaults to ``False``.
Expand Down Expand Up @@ -1039,6 +1039,8 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None:
if self.default_sort_order is not None:
self.default_sort_order = try_enum(SortOrder, self.default_sort_order)

self.default_reaction_emoji = None

reaction_emoji_ctx: dict = data.get("default_reaction_emoji")
if reaction_emoji_ctx is not None:
emoji_name = reaction_emoji_ctx.get("emoji_name")
Expand Down Expand Up @@ -1113,7 +1115,7 @@ async def edit(self, *, reason=None, **options):
position: :class:`int`
The new channel's position.
nsfw: :class:`bool`
To mark the channel as NSFW or not.
Whether the channel is marked as NSFW.
sync_permissions: :class:`bool`
Whether to sync permissions with the channel's new or pre-existing
category. Defaults to ``False``.
Expand Down Expand Up @@ -1476,7 +1478,7 @@ async def edit(self, *, reason=None, **options):
position: :class:`int`
The new channel's position.
nsfw: :class:`bool`
To mark the channel as NSFW or not.
Whether the channel is marked as NSFW.
sync_permissions: :class:`bool`
Whether to sync permissions with the channel's new or pre-existing
category. Defaults to ``False``.
Expand Down Expand Up @@ -1724,6 +1726,11 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel):
Extra features of the channel.

.. versionadded:: 2.0

nsfw: :class:`bool`
Whether the channel is marked as NSFW.

.. versionadded:: 2.7
"""

def __init__(
Expand Down Expand Up @@ -2042,6 +2049,7 @@ async def edit(
rtc_region: VoiceRegion | None = ...,
video_quality_mode: VideoQualityMode = ...,
slowmode_delay: int = ...,
nsfw: bool = ...,
reason: str | None = ...,
) -> VoiceChannel | None: ...

Expand Down Expand Up @@ -2092,6 +2100,15 @@ async def edit(self, *, reason=None, **options):

.. versionadded:: 2.0

slowmode_delay: :class:`int`
Specifies the slowmode rate limit for user in this channel, in seconds.
A value of `0` disables slowmode. The maximum value possible is `21600`.

nsfw: :class:`bool`
Whether the channel is marked as NSFW.

.. versionadded:: 2.7

Returns
-------
Optional[:class:`.VoiceChannel`]
Expand Down Expand Up @@ -2250,6 +2267,15 @@ class StageChannel(discord.abc.Messageable, VocalGuildChannel):
last_message_id: Optional[:class:`int`]
The ID of the last message sent to this channel. It may not always point to an existing or valid message.
.. versionadded:: 2.5

slowmode_delay: :class:`int`
Specifies the slowmode rate limit for user in this channel, in seconds.
The maximum value possible is `21600`.

nsfw: :class:`bool`
Whether the channel is marked as NSFW.

.. versionadded:: 2.7
"""

__slots__ = ("topic",)
Expand Down Expand Up @@ -2734,6 +2760,16 @@ async def edit(self, *, reason=None, **options):

.. versionadded:: 2.0

bitrate: :class:`int`
The channel's preferred audio bitrate in bits per second.

user_limit: :class:`int`
The channel's limit for number of members that can be in a voice channel.

slowmode_delay: :class:`int`
Specifies the slowmode rate limit for user in this channel, in seconds.
A value of `0` disables slowmode. The maximum value possible is `21600`.

Returns
-------
Optional[:class:`.StageChannel`]
Expand Down Expand Up @@ -2790,12 +2826,9 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
position: Optional[:class:`int`]
The position in the category list. This is a number that starts at 0. e.g. the
top category is position 0. Can be ``None`` if the channel was received in an interaction.
nsfw: :class:`bool`
If the channel is marked as "not safe for work".

.. note::

To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead.
flags: :class:`ChannelFlags`
Extra features of the channel.

Expand Down Expand Up @@ -2823,19 +2856,18 @@ def __init__(

def __repr__(self) -> str:
return (
"<CategoryChannel"
f" id={self.id} name={self.name!r} position={self.position} nsfw={self.nsfw}>"
f"<CategoryChannel id={self.id} name={self.name!r} position={self.position}"
)

def _update(self, guild: Guild, data: CategoryChannelPayload) -> None:
# This data will always exist
self.guild: Guild = guild
self.name: str = data["name"]
self.category_id: int | None = utils._get_as_snowflake(data, "parent_id")
self.nsfw = False

# This data may be missing depending on how this object is being created/updated
if not data.pop("_invoke_flag", False):
self.nsfw: bool = data.get("nsfw", False)
self.position: int = data.get("position")
self.flags: ChannelFlags = ChannelFlags._from_value(data.get("flags", 0))
self._fill_overwrites(data)
Expand All @@ -2849,23 +2881,18 @@ def type(self) -> ChannelType:
"""The channel's Discord type."""
return ChannelType.category

def is_nsfw(self) -> bool:
"""Checks if the category is NSFW."""
return self.nsfw

@utils.copy_doc(discord.abc.GuildChannel.clone)
async def clone(
self, *, name: str | None = None, reason: str | None = None
) -> CategoryChannel:
return await self._clone_impl({"nsfw": self.nsfw}, name=name, reason=reason)
return await self._clone_impl({}, name=name, reason=reason)

@overload
async def edit(
self,
*,
name: str = ...,
position: int = ...,
nsfw: bool = ...,
overwrites: Mapping[Role | Member, PermissionOverwrite] = ...,
reason: str | None = ...,
) -> CategoryChannel | None: ...
Expand Down Expand Up @@ -2893,8 +2920,6 @@ async def edit(self, *, reason=None, **options):
The new category's name.
position: :class:`int`
The new category's position.
nsfw: :class:`bool`
To mark the category as NSFW or not.
reason: Optional[:class:`str`]
The reason for editing this category. Shows up on the audit log.
overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`]
Expand Down Expand Up @@ -3042,6 +3067,16 @@ async def create_forum_channel(self, name: str, **options: Any) -> ForumChannel:
"""
return await self.guild.create_forum_channel(name, category=self, **options)

@utils.deprecated(
since="2.7",
removed="3.0",
reference="Category NSFW was never supported by the API.",
)
def is_nsfw(self) -> bool:
return False

# TODO: Remove in 3.0


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

Expand Down
Loading