Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions discord/app_commands/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down
8 changes: 4 additions & 4 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
24 changes: 19 additions & 5 deletions discord/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]): ...

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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::

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]] = {}
Expand Down
2 changes: 1 addition & 1 deletion discord/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Loading