From b1ded0103f1d0e177a1d6f53561dd2d921ee2d03 Mon Sep 17 00:00:00 2001 From: ToothyDev Date: Fri, 5 Jun 2026 15:53:49 +0200 Subject: [PATCH 1/2] Add spoiler channel flag and functions --- CHANGELOG.md | 3 +++ discord/channel.py | 21 +++++++++++++++++++++ discord/flags.py | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c63b835f8c..ba85ecc4ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ These changes are available on the `master` branch, but have not yet been releas ### Added +- Added `ChannelFlags.is_spoiler_channel` and `.is_spoiler()` function to all applicable + channel types. ([#3252](https://github.com/Pycord-Development/pycord/pull/3252)) + ### Changed ### Fixed diff --git a/discord/channel.py b/discord/channel.py index 2a6d5182ac..60d49b3b1b 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -312,6 +312,13 @@ def is_nsfw(self) -> bool: """Checks if the channel is NSFW.""" return self.nsfw + def is_spoiler(self) -> bool: + """Checks if the channel is a spoiler channel. + + .. versionadded:: 2.9 + """ + return self.flags.is_spoiler_channel + @property def last_message(self) -> Message | None: """Fetches the last message from this channel in cache. @@ -1810,6 +1817,13 @@ def is_nsfw(self) -> bool: """Checks if the channel is NSFW.""" return self.nsfw + def is_spoiler(self) -> bool: + """Checks if the channel is a spoiler channel. + + .. versionadded:: 2.9 + """ + return self.flags.is_spoiler_channel + @property def last_message(self) -> Message | None: """Fetches the last message from this channel in cache. @@ -2398,6 +2412,13 @@ def is_nsfw(self) -> bool: """Checks if the channel is NSFW.""" return self.nsfw + def is_spoiler(self) -> bool: + """Checks if the channel is a spoiler channel. + + .. versionadded:: 2.9 + """ + return self.flags.is_spoiler_channel + @property def last_message(self) -> Message | None: """Fetches the last message from this channel in cache. diff --git a/discord/flags.py b/discord/flags.py index 53c1ccd98b..b67240f9c7 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -1586,6 +1586,14 @@ def hide_media_download_options(self): """ return 1 << 15 + @flag_value + def is_spoiler_channel(self): + """:class:`bool`: Returns ``True`` if the channel is a spoiler channel. + + .. versionadded:: 2.9 + """ + return 1 << 21 + @fill_with_flags() class AttachmentFlags(BaseFlags): From 7b79faaa8be6f1f489e3e0c378363c257682defa Mon Sep 17 00:00:00 2001 From: ToothyDev Date: Fri, 5 Jun 2026 20:24:03 +0200 Subject: [PATCH 2/2] Add editing spoiler flag to channel editing functions --- CHANGELOG.md | 2 ++ discord/channel.py | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba85ecc4ca..3ef775f4c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ These changes are available on the `master` branch, but have not yet been releas - Added `ChannelFlags.is_spoiler_channel` and `.is_spoiler()` function to all applicable channel types. ([#3252](https://github.com/Pycord-Development/pycord/pull/3252)) +- Added `spoiler` parameter to the `edit()` function of all applicable channel types. + ([#3252](https://github.com/Pycord-Development/pycord/pull/3252)) ### Changed diff --git a/discord/channel.py b/discord/channel.py index 60d49b3b1b..a39cc1c415 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -811,6 +811,7 @@ async def edit( default_thread_slowmode_delay: int = ..., type: ChannelType = ..., overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ..., + spoiler: bool = ..., ) -> TextChannel | None: ... @overload @@ -867,6 +868,10 @@ async def edit(self, *, reason=None, **options): The new default slowmode delay in seconds for threads created in this channel. .. versionadded:: 2.3 + spoiler: :class:`bool` + Whether the channel should be a spoiler channel. Mutually exclusive with :attr:`nsfw`. + + .. versionadded:: 2.9 Returns ------- @@ -884,6 +889,10 @@ async def edit(self, *, reason=None, **options): HTTPException Editing the channel failed. """ + if "spoiler" in options: + options["flags"] = ChannelFlags._from_value(self.flags.value) + options["flags"].is_spoiler_channel = options.pop("spoiler") + payload = await self._edit(options, reason=reason) if payload is not None: # the payload will always be the proper channel payload @@ -1125,6 +1134,7 @@ async def edit( available_tags: list[ForumTag] = ..., require_tag: bool = ..., overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ..., + spoiler: bool = ..., ) -> ForumChannel | None: ... @overload @@ -1187,6 +1197,10 @@ async def edit(self, *, reason=None, **options): Whether a tag should be required to be specified when creating a thread in this channel. .. versionadded:: 2.3 + spoiler: :class:`bool` + Whether the channel should be a spoiler channel. Mutually exclusive with :attr:`nsfw`. + + .. versionadded:: 2.9 Returns ------- @@ -1207,6 +1221,10 @@ async def edit(self, *, reason=None, **options): if "require_tag" in options: options["flags"] = ChannelFlags._from_value(self.flags.value) options["flags"].require_tag = options.pop("require_tag") + if "spoiler" in options: + if "flags" not in options: + options["flags"] = ChannelFlags._from_value(self.flags.value) + options["flags"].is_spoiler_channel = options.pop("spoiler") payload = await self._edit(options, reason=reason) if payload is not None: @@ -1506,6 +1524,7 @@ async def edit( require_tag: bool = ..., hide_media_download_options: bool = ..., overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ..., + spoiler: bool = ..., ) -> ForumChannel | None: ... async def edit(self, *, reason=None, **options): @@ -1562,6 +1581,11 @@ async def edit(self, *, reason=None, **options): hide_media_download_options: :class:`bool` Whether media download options should be hidden in this media channel. + spoiler: :class:`bool` + Whether the channel should be a spoiler channel. Mutually exclusive with :attr:`nsfw`. + + .. versionadded:: 2.9 + Returns ------- Optional[:class:`.MediaChannel`] @@ -1579,14 +1603,18 @@ async def edit(self, *, reason=None, **options): Editing the channel failed. """ - if "require_tag" in options or "hide_media_download_options" in options: + if ( + "require_tag" in options + or "hide_media_download_options" in options + or "spoiler" in options + ): flags = ChannelFlags._from_value(self.flags.value) flags.require_tag = options.pop("require_tag", flags.require_tag) flags.hide_media_download_options = options.pop( "hide_media_download_options", flags.hide_media_download_options ) + flags.is_spoiler_channel = options.pop("spoiler", flags.is_spoiler_channel) options["flags"] = flags - payload = await self._edit(options, reason=reason) if payload is not None: # the payload will always be the proper channel payload @@ -2105,6 +2133,7 @@ async def edit( slowmode_delay: int = ..., nsfw: bool = ..., reason: str | None = ..., + spoiler: bool = ..., ) -> VoiceChannel | None: ... @overload @@ -2163,6 +2192,11 @@ async def edit(self, *, reason=None, **options): .. versionadded:: 2.7 + spoiler: :class:`bool` + Whether the channel should be a spoiler channel. Mutually exclusive with :attr:`nsfw`. + + .. versionadded:: 2.9 + Returns ------- Optional[:class:`.VoiceChannel`] @@ -2178,6 +2212,9 @@ async def edit(self, *, reason=None, **options): HTTPException Editing the channel failed. """ + if "spoiler" in options: + options["flags"] = ChannelFlags._from_value(self.flags.value) + options["flags"].is_spoiler_channel = options.pop("spoiler") payload = await self._edit(options, reason=reason) if payload is not None: