Skip to content

Commit 1e5c14b

Browse files
authored
feat: Support default_thread_rate_limit_per_user in channel creation (#9273)
feat: support `default_thread_rate_limit_per_user` in channel creation
1 parent ec3bcb9 commit 1e5c14b

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

packages/discord.js/src/managers/CategoryChannelChildManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class CategoryChannelChildManager extends DataManager {
5050
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds
5151
* @property {string} [rtcRegion] The specific region of the new channel.
5252
* @property {VideoQualityMode} [videoQualityMode] The camera video quality mode of the voice channel
53+
* @property {number} [defaultThreadRateLimitPerUser] The initial rate limit per user (slowmode)
54+
* to set on newly created threads in a channel.
5355
* @property {GuildForumTagData[]} [availableTags] The tags that can be used in this channel (forum only).
5456
* @property {DefaultReactionEmoji} [defaultReactionEmoji]
5557
* The emoji to show in the add reaction button on a thread in a guild forum channel.

packages/discord.js/src/managers/GuildChannelManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class GuildChannelManager extends CachedManager {
157157
rateLimitPerUser,
158158
rtcRegion,
159159
videoQualityMode,
160+
defaultThreadRateLimitPerUser,
160161
availableTags,
161162
defaultReactionEmoji,
162163
defaultAutoArchiveDuration,
@@ -181,6 +182,7 @@ class GuildChannelManager extends CachedManager {
181182
rate_limit_per_user: rateLimitPerUser,
182183
rtc_region: rtcRegion,
183184
video_quality_mode: videoQualityMode,
185+
default_thread_rate_limit_per_user: defaultThreadRateLimitPerUser,
184186
available_tags: availableTags?.map(availableTag => transformGuildForumTag(availableTag)),
185187
default_reaction_emoji: defaultReactionEmoji && transformGuildDefaultReaction(defaultReactionEmoji),
186188
default_auto_archive_duration: defaultAutoArchiveDuration,

packages/discord.js/src/structures/BaseGuildTextChannel.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ class BaseGuildTextChannel extends GuildChannel {
7474
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
7575
}
7676

77+
if ('default_thread_rate_limit_per_user' in data) {
78+
/**
79+
* The initial rate limit per user (slowmode) to set on newly created threads in a channel.
80+
* @type {?number}
81+
*/
82+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user;
83+
} else {
84+
this.defaultThreadRateLimitPerUser ??= null;
85+
}
86+
7787
if ('messages' in data) {
7888
for (const message of data.messages) this.messages._add(message);
7989
}

packages/discord.js/typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ export class BaseGuildEmoji extends Emoji {
636636
export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, true) {
637637
protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client<true>, immediatePatch?: boolean);
638638
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
639+
public defaultThreadRateLimitPerUser: number | null;
639640
public rateLimitPerUser: number | null;
640641
public nsfw: boolean;
641642
public threads: GuildTextThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
@@ -4823,6 +4824,7 @@ export interface CategoryCreateChannelOptions {
48234824
position?: number;
48244825
rtcRegion?: string;
48254826
videoQualityMode?: VideoQualityMode;
4827+
defaultThreadRateLimitPerUser?: number;
48264828
availableTags?: GuildForumTagData[];
48274829
defaultReactionEmoji?: DefaultReactionEmoji;
48284830
defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;

0 commit comments

Comments
 (0)