From c40f8dbb57edeba84667312b121051d1cd8752f6 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Mon, 15 Nov 2021 13:45:58 -0500 Subject: [PATCH 1/6] feat(ThreadManager): add user rate limit option on creation' --- src/managers/ThreadManager.js | 4 ++++ typings/index.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index 300041d0868e..cfbc6febc0d7 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -69,6 +69,8 @@ class ThreadManager extends CachedManager { * `GUILD_NEWS_THREAD` * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread * Can only be set when type will be `GUILD_PRIVATE_THREAD` + * @property {number} [rateLimitPerUser] The amount of seconds a user has to wait before sending another + * message. This value can be any integer between 1-21600 */ /** @@ -104,6 +106,7 @@ class ThreadManager extends CachedManager { type, invitable, reason, + rateLimitPerUser, } = {}) { let path = this.client.api.channels(this.channel.id); if (type && typeof type !== 'string' && typeof type !== 'number') { @@ -133,6 +136,7 @@ class ThreadManager extends CachedManager { auto_archive_duration: autoArchiveDuration, type: resolvedType, invitable: resolvedType === ChannelTypes.GUILD_PRIVATE_THREAD ? invitable : undefined, + rate_limit_per_user: rateLimitPerUser, }, reason, }); diff --git a/typings/index.d.ts b/typings/index.d.ts index 7f3bfe00e5de..c3b7bb5b67d4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5091,6 +5091,7 @@ export interface ThreadCreateOptions extends StartThreadOptio startMessage?: MessageResolvable; type?: AllowedThreadType; invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | 12 ? boolean : never; + rateLimitPerUser?: number; } export interface ThreadEditData { From 4bce851e1c3e5ce353264a72a671f564287a6e06 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Mon, 15 Nov 2021 14:14:04 -0500 Subject: [PATCH 2/6] docs: update description --- src/managers/ThreadManager.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index cfbc6febc0d7..9cd4f049e2c5 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -69,8 +69,7 @@ class ThreadManager extends CachedManager { * `GUILD_NEWS_THREAD` * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread * Can only be set when type will be `GUILD_PRIVATE_THREAD` - * @property {number} [rateLimitPerUser] The amount of seconds a user has to wait before sending another - * message. This value can be any integer between 1-21600 + * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds */ /** From 4b01ef311e2bb9ce31adbd3fa1c4ef6fa0c28ea2 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Wed, 17 Nov 2021 12:47:37 -0500 Subject: [PATCH 3/6] fix: interaction channel type should be GuildTextBasedChannels --- typings/index.d.ts | 4 ++-- typings/tests.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index c3b7bb5b67d4..d1e3151a671c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -28,6 +28,7 @@ import { APIApplicationCommandPermission, APIAuditLogChange, APIButtonComponent, + APIChannel, APIEmbed, APIEmoji, APIInteractionDataResolvedChannel, @@ -1190,7 +1191,7 @@ export class Interaction extends Base { private readonly _cacheType: Cached; protected constructor(client: Client, data: RawInteractionData); public applicationId: Snowflake; - public readonly channel: CacheTypeReducer; + public readonly channel: CacheTypeReducer; public channelId: Snowflake | null; public readonly createdAt: Date; public readonly createdTimestamp: number; @@ -1515,7 +1516,6 @@ export class MessageCollector extends Collector { export class MessageComponentInteraction extends Interaction { protected constructor(client: Client, data: RawMessageComponentInteractionData); - public readonly channel: CacheTypeReducer; public readonly component: CacheTypeReducer< Cached, MessageActionRowComponent, diff --git a/typings/tests.ts b/typings/tests.ts index ef693f983fc1..14d914f2bc9f 100644 --- a/typings/tests.ts +++ b/typings/tests.ts @@ -972,8 +972,10 @@ client.on('interactionCreate', async interaction => { // @ts-expect-error assertType>(interaction); assertType(interaction); + assertType(interaction.channel); } else if (interaction.inRawGuild()) { assertType(interaction.member); + assertType(interaction.channel); // @ts-expect-error consumeCachedInteraction(interaction); } else { From de9a5bdaf4d08e8229d4d4b37e6a9e8fe7359429 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Wed, 17 Nov 2021 12:49:43 -0500 Subject: [PATCH 4/6] chore: remove rate limit stuff --- src/managers/ThreadManager.js | 3 --- typings/index.d.ts | 2 -- 2 files changed, 5 deletions(-) diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index 9cd4f049e2c5..300041d0868e 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -69,7 +69,6 @@ class ThreadManager extends CachedManager { * `GUILD_NEWS_THREAD` * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread * Can only be set when type will be `GUILD_PRIVATE_THREAD` - * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds */ /** @@ -105,7 +104,6 @@ class ThreadManager extends CachedManager { type, invitable, reason, - rateLimitPerUser, } = {}) { let path = this.client.api.channels(this.channel.id); if (type && typeof type !== 'string' && typeof type !== 'number') { @@ -135,7 +133,6 @@ class ThreadManager extends CachedManager { auto_archive_duration: autoArchiveDuration, type: resolvedType, invitable: resolvedType === ChannelTypes.GUILD_PRIVATE_THREAD ? invitable : undefined, - rate_limit_per_user: rateLimitPerUser, }, reason, }); diff --git a/typings/index.d.ts b/typings/index.d.ts index d1e3151a671c..5771703e8307 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5091,14 +5091,12 @@ export interface ThreadCreateOptions extends StartThreadOptio startMessage?: MessageResolvable; type?: AllowedThreadType; invitable?: AllowedThreadType extends 'GUILD_PRIVATE_THREAD' | 12 ? boolean : never; - rateLimitPerUser?: number; } export interface ThreadEditData { name?: string; archived?: boolean; autoArchiveDuration?: ThreadAutoArchiveDuration; - rateLimitPerUser?: number; locked?: boolean; invitable?: boolean; } From dd1d883e440dd2a7eb718b38c586d1338597a482 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Wed, 17 Nov 2021 12:50:42 -0500 Subject: [PATCH 5/6] chore: well I guess one got through --- typings/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/typings/index.d.ts b/typings/index.d.ts index 5771703e8307..a4fe00811102 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5097,6 +5097,7 @@ export interface ThreadEditData { name?: string; archived?: boolean; autoArchiveDuration?: ThreadAutoArchiveDuration; + rateLimitPerUser?: number; locked?: boolean; invitable?: boolean; } From 64f1927e138f7b7e8964545391f3042616384118 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni Date: Thu, 18 Nov 2021 13:18:10 -0500 Subject: [PATCH 6/6] chore: adjust types for channel --- typings/index.d.ts | 8 +++++++- typings/tests.ts | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index a4fe00811102..ec98372d6eb5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1191,7 +1191,13 @@ export class Interaction extends Base { private readonly _cacheType: Cached; protected constructor(client: Client, data: RawInteractionData); public applicationId: Snowflake; - public readonly channel: CacheTypeReducer; + public readonly channel: CacheTypeReducer< + Cached, + GuildTextBasedChannel | null, + GuildTextBasedChannel | null, + GuildTextBasedChannel | null, + TextBasedChannels | null + >; public channelId: Snowflake | null; public readonly createdAt: Date; public readonly createdTimestamp: number; diff --git a/typings/tests.ts b/typings/tests.ts index 14d914f2bc9f..71095e705842 100644 --- a/typings/tests.ts +++ b/typings/tests.ts @@ -972,10 +972,10 @@ client.on('interactionCreate', async interaction => { // @ts-expect-error assertType>(interaction); assertType(interaction); - assertType(interaction.channel); + assertType(interaction.channel); } else if (interaction.inRawGuild()) { assertType(interaction.member); - assertType(interaction.channel); + assertType(interaction.channel); // @ts-expect-error consumeCachedInteraction(interaction); } else {