From f8e8d229897fa20088e7b28ca23f50fd2c5029bf Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:11:46 +0100 Subject: [PATCH] feat: Support `default_thread_rate_limit_per_user` in channel creation (#9273) feat: support `default_thread_rate_limit_per_user` in channel creation --- .../src/managers/CategoryChannelChildManager.js | 2 ++ .../discord.js/src/managers/GuildChannelManager.js | 2 ++ .../discord.js/src/structures/BaseGuildTextChannel.js | 10 ++++++++++ packages/discord.js/typings/index.d.ts | 2 ++ 4 files changed, 16 insertions(+) diff --git a/packages/discord.js/src/managers/CategoryChannelChildManager.js b/packages/discord.js/src/managers/CategoryChannelChildManager.js index 347526ab17661..dd0f672615124 100644 --- a/packages/discord.js/src/managers/CategoryChannelChildManager.js +++ b/packages/discord.js/src/managers/CategoryChannelChildManager.js @@ -50,6 +50,8 @@ class CategoryChannelChildManager extends DataManager { * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds * @property {string} [rtcRegion] The specific region of the new channel. * @property {VideoQualityMode} [videoQualityMode] The camera video quality mode of the voice channel + * @property {number} [defaultThreadRateLimitPerUser] The initial rate limit per user (slowmode) + * to set on newly created threads in a channel. * @property {GuildForumTagData[]} [availableTags] The tags that can be used in this channel (forum only). * @property {DefaultReactionEmoji} [defaultReactionEmoji] * The emoji to show in the add reaction button on a thread in a guild forum channel. diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index 2c5d1466cbd75..376965c250d16 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -157,6 +157,7 @@ class GuildChannelManager extends CachedManager { rateLimitPerUser, rtcRegion, videoQualityMode, + defaultThreadRateLimitPerUser, availableTags, defaultReactionEmoji, defaultAutoArchiveDuration, @@ -181,6 +182,7 @@ class GuildChannelManager extends CachedManager { rate_limit_per_user: rateLimitPerUser, rtc_region: rtcRegion, video_quality_mode: videoQualityMode, + default_thread_rate_limit_per_user: defaultThreadRateLimitPerUser, available_tags: availableTags?.map(availableTag => transformGuildForumTag(availableTag)), default_reaction_emoji: defaultReactionEmoji && transformGuildDefaultReaction(defaultReactionEmoji), default_auto_archive_duration: defaultAutoArchiveDuration, diff --git a/packages/discord.js/src/structures/BaseGuildTextChannel.js b/packages/discord.js/src/structures/BaseGuildTextChannel.js index f7d9d69889a68..9b8490ecc995d 100644 --- a/packages/discord.js/src/structures/BaseGuildTextChannel.js +++ b/packages/discord.js/src/structures/BaseGuildTextChannel.js @@ -74,6 +74,16 @@ class BaseGuildTextChannel extends GuildChannel { this.defaultAutoArchiveDuration = data.default_auto_archive_duration; } + if ('default_thread_rate_limit_per_user' in data) { + /** + * The initial rate limit per user (slowmode) to set on newly created threads in a channel. + * @type {?number} + */ + this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user; + } else { + this.defaultThreadRateLimitPerUser ??= null; + } + if ('messages' in data) { for (const message of data.messages) this.messages._add(message); } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index ff98527e221cb..1a80284102b0f 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -636,6 +636,7 @@ export class BaseGuildEmoji extends Emoji { export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, true) { protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean); public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; + public defaultThreadRateLimitPerUser: number | null; public rateLimitPerUser: number | null; public nsfw: boolean; public threads: GuildTextThreadManager; @@ -4823,6 +4824,7 @@ export interface CategoryCreateChannelOptions { position?: number; rtcRegion?: string; videoQualityMode?: VideoQualityMode; + defaultThreadRateLimitPerUser?: number; availableTags?: GuildForumTagData[]; defaultReactionEmoji?: DefaultReactionEmoji; defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;