Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Support default_thread_rate_limit_per_user in channel creation (
#9273)

feat: support `default_thread_rate_limit_per_user` in channel creation
  • Loading branch information
Jiralite committed Sep 19, 2023
1 parent ec3bcb9 commit 1e5c14b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/src/managers/GuildChannelManager.js
Expand Up @@ -157,6 +157,7 @@ class GuildChannelManager extends CachedManager {
rateLimitPerUser,
rtcRegion,
videoQualityMode,
defaultThreadRateLimitPerUser,
availableTags,
defaultReactionEmoji,
defaultAutoArchiveDuration,
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions packages/discord.js/src/structures/BaseGuildTextChannel.js
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -636,6 +636,7 @@ export class BaseGuildEmoji extends Emoji {
export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel, true) {
protected constructor(guild: Guild, data?: RawGuildChannelData, client?: Client<true>, immediatePatch?: boolean);
public defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
public defaultThreadRateLimitPerUser: number | null;
public rateLimitPerUser: number | null;
public nsfw: boolean;
public threads: GuildTextThreadManager<AllowedThreadTypeForTextChannel | AllowedThreadTypeForNewsChannel>;
Expand Down Expand Up @@ -4823,6 +4824,7 @@ export interface CategoryCreateChannelOptions {
position?: number;
rtcRegion?: string;
videoQualityMode?: VideoQualityMode;
defaultThreadRateLimitPerUser?: number;
availableTags?: GuildForumTagData[];
defaultReactionEmoji?: DefaultReactionEmoji;
defaultAutoArchiveDuration?: ThreadAutoArchiveDuration;
Expand Down

0 comments on commit 1e5c14b

Please sign in to comment.