From 79c508311fa45a7e41484c181d54a9ea9324953d Mon Sep 17 00:00:00 2001 From: Puncher <65789180+Puncher1@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:31:14 +0100 Subject: [PATCH] Add support for default_thread_slowmode_delay in TextChannel --- discord/channel.py | 10 ++++++++++ discord/guild.py | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/discord/channel.py b/discord/channel.py index 9636bc229..6cd74c71a 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -160,6 +160,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): The default auto archive duration in minutes for threads created in this channel. .. versionadded:: 2.0 + default_thread_slowmode_delay: :class:`int` + The default slowmode delay in seconds for threads created in this channel. + + .. versionadded:: 2.3 """ __slots__ = ( @@ -176,6 +180,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): '_type', 'last_message_id', 'default_auto_archive_duration', + 'default_thread_slowmode_delay', ) def __init__(self, *, state: ConnectionState, guild: Guild, data: Union[TextChannelPayload, NewsChannelPayload]): @@ -206,6 +211,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): # Does this need coercion into `int`? No idea yet. self.slowmode_delay: int = data.get('rate_limit_per_user', 0) self.default_auto_archive_duration: ThreadArchiveDuration = data.get('default_auto_archive_duration', 1440) + self.default_thread_slowmode_delay: int = data.get('default_thread_rate_limit_per_user', 0) self._type: Literal[0, 5] = data.get('type', self._type) self.last_message_id: Optional[int] = utils._get_as_snowflake(data, 'last_message_id') self._fill_overwrites(data) @@ -301,6 +307,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): category: Optional[CategoryChannel] = ..., slowmode_delay: int = ..., default_auto_archive_duration: ThreadArchiveDuration = ..., + default_thread_slowmode_delay: int = ..., type: ChannelType = ..., overwrites: Mapping[OverwriteKeyT, PermissionOverwrite] = ..., ) -> TextChannel: @@ -359,7 +366,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): Must be one of ``60``, ``1440``, ``4320``, or ``10080``. .. versionadded:: 2.0 + default_thread_slowmode_delay: :class:`int` + The new default slowmode delay in seconds for threads created in this channel. + .. versionadded:: 2.3 Raises ------ ValueError diff --git a/discord/guild.py b/discord/guild.py index e1cc7814e..0a901fbe3 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -1200,6 +1200,7 @@ class Guild(Hashable): nsfw: bool = MISSING, overwrites: Mapping[Union[Role, Member], PermissionOverwrite] = MISSING, default_auto_archive_duration: int = MISSING, + default_thread_slowmode_delay: int = MISSING, ) -> TextChannel: """|coro| @@ -1273,6 +1274,10 @@ class Guild(Hashable): Must be one of ``60``, ``1440``, ``4320``, or ``10080``. .. versionadded:: 2.0 + default_thread_slowmode_delay: :class:`int` + The default slowmode delay in seconds for threads created in the text channel. + + .. versionadded:: 2.3 reason: Optional[:class:`str`] The reason for creating this channel. Shows up on the audit log. @@ -1305,7 +1310,10 @@ class Guild(Hashable): options['nsfw'] = nsfw if default_auto_archive_duration is not MISSING: - options["default_auto_archive_duration"] = default_auto_archive_duration + options['default_auto_archive_duration'] = default_auto_archive_duration + + if default_thread_slowmode_delay is not MISSING: + options['default_thread_rate_limit_per_user'] = default_thread_slowmode_delay data = await self._create_channel( name,