Skip to content

Commit 2d17b74

Browse files
authored
feat: add rate_limit_per_user param for create thread methods (#1359)
1 parent 758d80c commit 2d17b74

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

interactions/api/http/http_requests/threads.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ async def create_thread(
180180
auto_archive_duration: int,
181181
thread_type: Absent[int] = MISSING,
182182
invitable: Absent[bool] = MISSING,
183+
rate_limit_per_user: Absent[int] = MISSING,
183184
message_id: Absent["Snowflake_Type"] = MISSING,
184185
reason: Absent[str] = MISSING,
185186
) -> discord_typings.ThreadChannelData:
@@ -191,15 +192,20 @@ async def create_thread(
191192
name: The name of the thread
192193
auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
193194
thread_type: The type of thread, defaults to public. ignored if creating thread from a message
194-
invitable:
195+
invitable: Whether non-moderators can add other non-moderators to a thread; only available when creating a private thread
196+
rate_limit_per_user: The time users must wait between sending messages (0-21600)
195197
message_id: An optional message to create a thread from.
196198
reason: An optional reason for the audit log
197199
198200
Returns:
199201
The created thread
200202
201203
"""
202-
payload = {"name": name, "auto_archive_duration": auto_archive_duration}
204+
payload = {
205+
"name": name,
206+
"auto_archive_duration": auto_archive_duration,
207+
"rate_limit_per_user": rate_limit_per_user,
208+
}
203209
if message_id:
204210
return await self.request(
205211
Route(

interactions/models/discord/channel.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ async def create_thread(
556556
message: Absent[Snowflake_Type] = MISSING,
557557
thread_type: Absent[ChannelType] = MISSING,
558558
invitable: Absent[bool] = MISSING,
559+
rate_limit_per_user: Absent[int] = MISSING,
559560
auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY,
560561
reason: Absent[str] = None,
561562
) -> "TYPE_THREAD_CHANNEL":
@@ -567,6 +568,7 @@ async def create_thread(
567568
message: The message to connect this thread to. Required for news channel.
568569
thread_type: Is the thread private or public. Not applicable to news channel, it will always be GUILD_NEWS_THREAD.
569570
invitable: whether non-moderators can add other non-moderators to a thread. Only applicable when creating a private thread.
571+
rate_limit_per_user: The time users must wait between sending messages (0-21600).
570572
auto_archive_duration: Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted.
571573
reason: The reason for creating this thread.
572574
@@ -588,6 +590,7 @@ async def create_thread(
588590
name=name,
589591
thread_type=thread_type,
590592
invitable=invitable,
593+
rate_limit_per_user=rate_limit_per_user,
591594
auto_archive_duration=auto_archive_duration,
592595
message_id=to_optional_snowflake(message),
593596
reason=reason,
@@ -1740,6 +1743,7 @@ async def create_public_thread(
17401743
self,
17411744
name: str,
17421745
auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY,
1746+
rate_limit_per_user: Absent[int] = MISSING,
17431747
reason: Absent[str] = None,
17441748
) -> "GuildPublicThread":
17451749
"""
@@ -1748,6 +1752,7 @@ async def create_public_thread(
17481752
Args:
17491753
name: 1-100 character thread name.
17501754
auto_archive_duration: Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted.
1755+
rate_limit_per_user: The time users must wait between sending messages (0-21600).
17511756
reason: The reason for creating this thread.
17521757
17531758
Returns:
@@ -1758,6 +1763,7 @@ async def create_public_thread(
17581763
name=name,
17591764
thread_type=ChannelType.GUILD_PUBLIC_THREAD,
17601765
auto_archive_duration=auto_archive_duration,
1766+
rate_limit_per_user=rate_limit_per_user,
17611767
reason=reason,
17621768
)
17631769

@@ -1766,14 +1772,16 @@ async def create_private_thread(
17661772
name: str,
17671773
invitable: Absent[bool] = MISSING,
17681774
auto_archive_duration: AutoArchiveDuration = AutoArchiveDuration.ONE_DAY,
1775+
rate_limit_per_user: Absent[int] = MISSING,
17691776
reason: Absent[str] = None,
17701777
) -> "GuildPrivateThread":
17711778
"""
17721779
Creates a new private thread in this channel.
17731780
17741781
Args:
17751782
name: 1-100 character thread name.
1776-
invitable: whether non-moderators can add other non-moderators to a thread.
1783+
invitable: Whether non-moderators can add other non-moderators to a thread.
1784+
rate_limit_per_user: The time users must wait between sending messages (0-21600).
17771785
auto_archive_duration: Time before the thread will be automatically archived. Note 3 day and 7 day archive durations require the server to be boosted.
17781786
reason: The reason for creating this thread.
17791787
@@ -1785,6 +1793,7 @@ async def create_private_thread(
17851793
name=name,
17861794
thread_type=ChannelType.GUILD_PRIVATE_THREAD,
17871795
invitable=invitable,
1796+
rate_limit_per_user=rate_limit_per_user,
17881797
auto_archive_duration=auto_archive_duration,
17891798
reason=reason,
17901799
)

0 commit comments

Comments
 (0)