From 58f7e5299bdd5b9de313219a086f814a621f3fd5 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 29 Oct 2023 13:16:41 +0700 Subject: [PATCH] feat: support `default_thread_rate_limit_per_user` in channel creation #9339 djs --- src/managers/GuildChannelManager.js | 2 ++ src/structures/BaseGuildTextChannel.js | 10 ++++++++++ src/structures/CategoryChannel.js | 2 ++ typings/index.d.ts | 2 ++ 4 files changed, 16 insertions(+) diff --git a/src/managers/GuildChannelManager.js b/src/managers/GuildChannelManager.js index 85db817..84da081 100644 --- a/src/managers/GuildChannelManager.js +++ b/src/managers/GuildChannelManager.js @@ -150,6 +150,7 @@ class GuildChannelManager extends CachedManager { defaultReactionEmoji, defaultSortOrder, defaultForumLayout, + defaultThreadRateLimitPerUser, reason, } = {}, ) { @@ -191,6 +192,7 @@ class GuildChannelManager extends CachedManager { default_reaction_emoji: defaultReactionEmoji && transformGuildDefaultReaction(defaultReactionEmoji), default_sort_order: sortMode, default_forum_layout: layoutMode, + default_thread_rate_limit_per_user: defaultThreadRateLimitPerUser, }, reason, }); diff --git a/src/structures/BaseGuildTextChannel.js b/src/structures/BaseGuildTextChannel.js index 3a19550..0b475a7 100644 --- a/src/structures/BaseGuildTextChannel.js +++ b/src/structures/BaseGuildTextChannel.js @@ -81,6 +81,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/src/structures/CategoryChannel.js b/src/structures/CategoryChannel.js index 6a1574b..3e24e53 100644 --- a/src/structures/CategoryChannel.js +++ b/src/structures/CategoryChannel.js @@ -62,6 +62,8 @@ class CategoryChannel extends GuildChannel { * @property {?DefaultReactionEmoji} [defaultReactionEmoji] The emoji to set as the default reaction emoji * @property {number} [defaultThreadRateLimitPerUser] The rate limit per user (slowmode) to set on forum posts * @property {?SortOrderType} [defaultSortOrder] The default sort order mode to set on the new channel + * @property {number} [defaultThreadRateLimitPerUser] The initial rate limit per user (slowmode) + * to set on newly created threads in a channel. * @property {string} [reason] Reason for creating the new channel */ diff --git a/typings/index.d.ts b/typings/index.d.ts index 2a6fcc0..e110961 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -768,6 +768,7 @@ export class BaseGuildEmoji extends Emoji { export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) { 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; @@ -5595,6 +5596,7 @@ export interface CategoryCreateChannelOptions { defaultReactionEmoji?: DefaultReactionEmoji; defaultSortOrder?: SortOrderType; defaultForumLayout?: ForumLayoutType; + defaultThreadRateLimitPerUser?: number; reason?: string; }