diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 0acf59676..242b6f048 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -286,6 +286,7 @@ class GuildChannel extends Channel { * Lock the permissions of the channel to what the parent's permissions are * @property {OverwriteResolvable[]|Collection} [permissionOverwrites] * Permission overwrites for the channel + * @property {number} [rateLimitPerUser] The ratelimit per user for the channel */ /** @@ -323,6 +324,7 @@ class GuildChannel extends Channel { user_limit: typeof data.userLimit !== 'undefined' ? data.userLimit : this.userLimit, parent_id: data.parentID, lock_permissions: data.lockPermissions, + rate_limit_per_user: data.rateLimitPerUser, permission_overwrites, }, reason, diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 698e23f20..6e053e5d0 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -43,6 +43,12 @@ class TextChannel extends GuildChannel { */ this.lastMessageID = data.last_message_id; + /** + * The ratelimit per user for this channel + * @type {number} + */ + this.rateLimitPerUser = data.rate_limit_per_user || 0; + /** * The timestamp when the last pinned message was pinned, if there was one * @type {?number} @@ -52,6 +58,16 @@ class TextChannel extends GuildChannel { if (data.messages) for (const message of data.messages) this.messages.add(message); } + /** + * Sets the rate limit per user for this channel. + * @param {number} rateLimitPerUser The new ratelimit + * @param {string} [reason] Reason for changing the channel's ratelimits + * @returns {Promise} + */ + setRateLimitPerUser(rateLimitPerUser, reason) { + return this.edit({ rateLimitPerUser }, reason); + } + /** * Sets whether this channel is flagged as NSFW. * @param {boolean} nsfw Whether the channel should be considered NSFW diff --git a/typings/index.d.ts b/typings/index.d.ts index 80ba73526..174510d81 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1045,9 +1045,11 @@ declare module 'discord.js' { public readonly members: Collection; public messages: MessageStore; public nsfw: boolean; + public rateLimitPerUser: number; public topic: string; public createWebhook(name: string, options?: { avatar?: BufferResolvable | Base64Resolvable, reason?: string }): Promise; public setNSFW(nsfw: boolean, reason?: string): Promise; + public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise; public fetchWebhooks(): Promise>; } @@ -1529,6 +1531,7 @@ declare module 'discord.js' { bitrate?: number; userLimit?: number; parentID?: Snowflake; + rateLimitPerUser?: number; lockPermissions?: boolean; permissionOverwrites?: OverwriteResolvable[] | Collection; };