Add bypass slowmode permissions

This commit is contained in:
Sacul
2026-02-23 04:53:02 +08:00
committed by GitHub
parent 680ca5ee20
commit e45c8e60e1
5 changed files with 29 additions and 22 deletions

View File

@@ -597,8 +597,7 @@ class AppCommandChannel(Hashable):
slowmode_delay: :class:`int`
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.
Bots and users with :attr:`~discord.Permissions.bypass_slowmode` bypass slowmode.
.. versionadded:: 2.6
nsfw: :class:`bool`
@@ -779,8 +778,7 @@ class AppCommandThread(Hashable):
slowmode_delay: :class:`int`
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.
Bots and users with :attr:`~discord.Permissions.bypass_slowmode` bypass slowmode.
.. versionadded:: 2.6
message_count: :class:`int`

View File

@@ -322,8 +322,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
slowmode_delay: :class:`int`
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.
Bots and users with :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`
@@ -1516,8 +1515,7 @@ class VoiceChannel(VocalGuildChannel):
slowmode_delay: :class:`int`
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.
Bots and users with :attr:`~Permissions.bypass_slowmode` bypass slowmode.
.. versionadded:: 2.2
"""
@@ -1744,8 +1742,7 @@ class StageChannel(VocalGuildChannel):
slowmode_delay: :class:`int`
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.
Bots and users with :attr:`~Permissions.bypass_slowmode` bypass slowmode.
.. versionadded:: 2.2
"""
@@ -2409,8 +2406,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable):
slowmode_delay: :class:`int`
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.
Bots and users with :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`

View File

@@ -1453,7 +1453,7 @@ class PartialMessage(Hashable):
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 @@ class PartialMessage(Hashable):
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 @@ class PartialMessage(Hashable):
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

View File

@@ -95,6 +95,7 @@ if TYPE_CHECKING:
create_polls: BoolOrNoneT
use_external_apps: BoolOrNoneT
pin_messages: BoolOrNoneT
bypass_slowmode: BoolOrNoneT
class _PermissionsKwargs(_BasePermissionsKwargs[bool]): ...
@@ -253,7 +254,7 @@ class Permissions(BaseFlags):
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 @@ class Permissions(BaseFlags):
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 @@ class Permissions(BaseFlags):
.. 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 @@ class Permissions(BaseFlags):
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 @@ class Permissions(BaseFlags):
@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 @@ class Permissions(BaseFlags):
"""
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]] = {}

View File

@@ -103,8 +103,7 @@ class Thread(Messageable, Hashable):
slowmode_delay: :class:`int`
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.
Bots and users with :attr:`~Permissions.bypass_slowmode` bypass slowmode.
message_count: :class:`int`
An approximate number of messages in this thread.
member_count: :class:`int`