diff --git a/discord/app_commands/models.py b/discord/app_commands/models.py index b51339c2683d..3e4ed39aa565 100644 --- a/discord/app_commands/models.py +++ b/discord/app_commands/models.py @@ -598,7 +598,7 @@ class AppCommandChannel(Hashable): The number of seconds a member must wait between sending messages in this channel. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~discord.Permissions.manage_channels` or - :attr:`~discord.Permissions.manage_messages` bypass slowmode. + :attr:`~discord.Permissions.bypass_slowmode` bypass slowmode. .. versionadded:: 2.6 nsfw: :class:`bool` @@ -780,7 +780,7 @@ class AppCommandThread(Hashable): The number of seconds a member must wait between sending messages in this thread. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~discord.Permissions.manage_channels` or - :attr:`~discord.Permissions.manage_messages` bypass slowmode. + :attr:`~discord.Permissions.bypass_slowmode` bypass slowmode. .. versionadded:: 2.6 message_count: :class:`int` diff --git a/discord/channel.py b/discord/channel.py index 17a1c0fb2d67..9af4846201fb 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -323,7 +323,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): The number of seconds a member must wait between sending messages in this channel. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~Permissions.manage_channels` or - :attr:`~Permissions.manage_messages` bypass slowmode. + :attr:`~Permissions.bypass_slowmode` bypass slowmode. nsfw: :class:`bool` If the channel is marked as "not safe for work" or "age restricted". default_auto_archive_duration: :class:`int` @@ -1517,7 +1517,7 @@ class VoiceChannel(VocalGuildChannel): The number of seconds a member must wait between sending messages in this channel. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~Permissions.manage_channels` or - :attr:`~Permissions.manage_messages` bypass slowmode. + :attr:`~Permissions.bypass_slowmode` bypass slowmode. .. versionadded:: 2.2 """ @@ -1745,7 +1745,7 @@ class StageChannel(VocalGuildChannel): The number of seconds a member must wait between sending messages in this channel. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~Permissions.manage_channels` or - :attr:`~Permissions.manage_messages` bypass slowmode. + :attr:`~Permissions.bypass_slowmode` bypass slowmode. .. versionadded:: 2.2 """ @@ -2410,7 +2410,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable): The number of seconds a member must wait between creating threads in this forum. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~Permissions.manage_channels` or - :attr:`~Permissions.manage_messages` bypass slowmode. + :attr:`~Permissions.bypass_slowmode` bypass slowmode. nsfw: :class:`bool` If the forum is marked as "not safe for work" or "age restricted". default_auto_archive_duration: :class:`int` diff --git a/discord/message.py b/discord/message.py index 9db351d54a80..154682275f95 100644 --- a/discord/message.py +++ b/discord/message.py @@ -1453,7 +1453,7 @@ async def pin(self, *, reason: Optional[str] = None) -> None: Pins the message. - You must have :attr:`~Permissions.manage_messages` to do + You must have :attr:`~Permissions.pin_messages` to do this in a non-private channel context. Parameters @@ -1471,7 +1471,7 @@ async def pin(self, *, reason: Optional[str] = None) -> None: The message or channel was not found or deleted. HTTPException Pinning the message failed, probably due to the channel - having more than 50 pinned messages. + having more than 250 pinned messages. """ await self._state.http.pin_message(self.channel.id, self.id, reason=reason) @@ -1483,7 +1483,7 @@ async def unpin(self, *, reason: Optional[str] = None) -> None: Unpins the message. - You must have :attr:`~Permissions.manage_messages` to do + You must have :attr:`~Permissions.pin_messages` to do this in a non-private channel context. Parameters diff --git a/discord/permissions.py b/discord/permissions.py index a1e0d21c2c6d..e09af313c181 100644 --- a/discord/permissions.py +++ b/discord/permissions.py @@ -95,6 +95,7 @@ class _BasePermissionsKwargs(Generic[BoolOrNoneT], TypedDict, total=False): create_polls: BoolOrNoneT use_external_apps: BoolOrNoneT pin_messages: BoolOrNoneT + bypass_slowmode: BoolOrNoneT class _PermissionsKwargs(_BasePermissionsKwargs[bool]): ... @@ -253,7 +254,7 @@ def all(cls) -> Self: permissions set to ``True``. """ # Some of these are 0 because we don't want to set unnecessary bits - return cls(0b0000_0000_0000_1111_0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111) + return cls(0b0000_0000_0001_1111_0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111) @classmethod def _timeout_mask(cls) -> int: @@ -273,6 +274,7 @@ def _dm_permissions(cls) -> Self: base.create_public_threads = False base.manage_threads = False base.send_messages_in_threads = False + base.bypass_slowmode = False return base @classmethod @@ -326,8 +328,11 @@ def all_channel(cls) -> Self: .. versionchanged:: 2.4 Added :attr:`send_polls`, :attr:`send_voice_messages`, attr:`use_external_sounds`, :attr:`use_embedded_activities`, and :attr:`use_external_apps` permissions. + + .. versionchanged:: 2.7 + Added :attr:`pin_messages` and :attr:`bypass_slowmode` permissions. """ - return cls(0b0000_0000_0000_1110_0110_0100_1111_1101_1011_0011_1111_0111_1111_1111_0101_0001) + return cls(0b0000_0000_0001_1110_0110_0100_1111_1101_1011_0011_1111_0111_1111_1111_0101_0001) @classmethod def general(cls) -> Self: @@ -377,9 +382,9 @@ def text(cls) -> Self: Added :attr:`send_polls` and :attr:`use_external_apps` permissions. .. versionchanged:: 2.7 - Added :attr:`pin_messages` permission. + Added :attr:`pin_messages` and :attr:`bypass_slowmode` permissions. """ - return cls(0b0000_0000_0000_1110_0100_0000_0111_1100_1000_0000_0000_0111_1111_1000_0100_0000) + return cls(0b0000_0000_0001_1110_0100_0000_0111_1100_1000_0000_0000_0111_1111_1000_0100_0000) @classmethod def voice(cls) -> Self: @@ -577,7 +582,7 @@ def send_tts_messages(self) -> int: @flag_value def manage_messages(self) -> int: - """:class:`bool`: Returns ``True`` if a user can delete messages or bypass slowmode in a text channel. + """:class:`bool`: Returns ``True`` if a user can delete messages in a text channel. .. note:: @@ -884,6 +889,14 @@ def pin_messages(self) -> int: """ return 1 << 51 + @flag_value + def bypass_slowmode(self) -> int: + """:class:`bool`: Returns ``True`` if a user can bypass slowmode. + + .. versionadded:: 2.7 + """ + return 1 << 52 + def _augment_from_permissions(cls): cls.VALID_NAMES = set(Permissions.VALID_FLAGS) @@ -1009,6 +1022,7 @@ class PermissionOverwrite: create_polls: Optional[bool] use_external_apps: Optional[bool] pin_messages: Optional[bool] + bypass_slowmode: Optional[bool] def __init__(self, **kwargs: Unpack[_PermissionOverwriteKwargs]) -> None: self._values: Dict[str, Optional[bool]] = {} diff --git a/discord/threads.py b/discord/threads.py index 1700a5e61e76..d9e2ae9b9162 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -104,7 +104,7 @@ class Thread(Messageable, Hashable): The number of seconds a member must wait between sending messages in this thread. A value of ``0`` denotes that it is disabled. Bots and users with :attr:`~Permissions.manage_channels` or - :attr:`~Permissions.manage_messages` bypass slowmode. + :attr:`~Permissions.bypass_slowmode` bypass slowmode. message_count: :class:`int` An approximate number of messages in this thread. member_count: :class:`int`