Skip to content

Commit 33cbe88

Browse files
fix: add missing kwargs to TextChannel.create_thread and similar methods (#2350)
* add missing create_thread kwargs * style(pre-commit): auto fixes from pre-commit.com hooks * fix and changelog --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e9efa2c commit 33cbe88

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ These changes are available on the `master` branch, but have not yet been releas
9191
([#2273](https://github.com/Pycord-Development/pycord/pull/2273))
9292
- Added `AttachmentFlags` and attachment attributes `expires_at`, `issued_at` and `hm`.
9393
([#2342](https://github.com/Pycord-Development/pycord/pull/2342))
94+
- Added `invitable` and `slowmode_delay` to `Thread` creation methods.
95+
([#2350](https://github.com/Pycord-Development/pycord/pull/2350))
9496

9597
### Changed
9698

discord/channel.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,8 @@ async def create_thread(
868868
message: Snowflake | None = None,
869869
auto_archive_duration: ThreadArchiveDuration = MISSING,
870870
type: ChannelType | None = None,
871+
slowmode_delay: int | None = None,
872+
invitable: bool | None = None,
871873
reason: str | None = None,
872874
) -> Thread:
873875
"""|coro|
@@ -894,6 +896,12 @@ async def create_thread(
894896
The type of thread to create. If a ``message`` is passed then this parameter
895897
is ignored, as a thread created with a message is always a public thread.
896898
By default, this creates a private thread if this is ``None``.
899+
slowmode_delay: Optional[:class:`int`]
900+
Specifies the slowmode rate limit for users in this thread, in seconds.
901+
A value of ``0`` disables slowmode. The maximum value possible is ``21600``.
902+
invitable: Optional[:class:`bool`]
903+
Whether non-moderators can add other non-moderators to this thread.
904+
Only available for private threads, where it defaults to True.
897905
reason: :class:`str`
898906
The reason for creating a new thread. Shows up on the audit log.
899907
@@ -920,6 +928,8 @@ async def create_thread(
920928
auto_archive_duration=auto_archive_duration
921929
or self.default_auto_archive_duration,
922930
type=type.value,
931+
rate_limit_per_user=slowmode_delay or 0,
932+
invitable=invitable,
923933
reason=reason,
924934
)
925935
else:
@@ -929,6 +939,7 @@ async def create_thread(
929939
name=name,
930940
auto_archive_duration=auto_archive_duration
931941
or self.default_auto_archive_duration,
942+
rate_limit_per_user=slowmode_delay or 0,
932943
reason=reason,
933944
)
934945

discord/http.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,13 @@ def start_thread_with_message(
11301130
*,
11311131
name: str,
11321132
auto_archive_duration: threads.ThreadArchiveDuration,
1133+
rate_limit_per_user: int,
11331134
reason: str | None = None,
11341135
) -> Response[threads.Thread]:
11351136
payload = {
11361137
"name": name,
11371138
"auto_archive_duration": auto_archive_duration,
1139+
"rate_limit_per_user": rate_limit_per_user,
11381140
}
11391141

11401142
route = Route(
@@ -1152,13 +1154,15 @@ def start_thread_without_message(
11521154
name: str,
11531155
auto_archive_duration: threads.ThreadArchiveDuration,
11541156
type: threads.ThreadType,
1155-
invitable: bool = True,
1157+
rate_limit_per_user: int,
1158+
invitable: bool,
11561159
reason: str | None = None,
11571160
) -> Response[threads.Thread]:
11581161
payload = {
11591162
"name": name,
11601163
"auto_archive_duration": auto_archive_duration,
11611164
"type": type,
1165+
"rate_limit_per_user": rate_limit_per_user,
11621166
"invitable": invitable,
11631167
}
11641168

discord/message.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,11 @@ async def clear_reactions(self) -> None:
17301730
await self._state.http.clear_reactions(self.channel.id, self.id)
17311731

17321732
async def create_thread(
1733-
self, *, name: str, auto_archive_duration: ThreadArchiveDuration = MISSING
1733+
self,
1734+
*,
1735+
name: str,
1736+
auto_archive_duration: ThreadArchiveDuration = MISSING,
1737+
slowmode_delay: int = MISSING,
17341738
) -> Thread:
17351739
"""|coro|
17361740
@@ -1747,9 +1751,12 @@ async def create_thread(
17471751
----------
17481752
name: :class:`str`
17491753
The name of the thread.
1750-
auto_archive_duration: :class:`int`
1754+
auto_archive_duration: Optional[:class:`int`]
17511755
The duration in minutes before a thread is automatically archived for inactivity.
17521756
If not provided, the channel's default auto archive duration is used.
1757+
slowmode_delay: Optional[:class:`int`]
1758+
Specifies the slowmode rate limit for user in this thread, in seconds.
1759+
A value of ``0`` disables slowmode. The maximum value possible is ``21600``.
17531760
17541761
Returns
17551762
-------
@@ -1778,6 +1785,7 @@ async def create_thread(
17781785
name=name,
17791786
auto_archive_duration=auto_archive_duration
17801787
or default_auto_archive_duration,
1788+
rate_limit_per_user=slowmode_delay or 0,
17811789
)
17821790

17831791
self.thread = Thread(guild=self.guild, state=self._state, data=data)

0 commit comments

Comments
 (0)