From 6c5dbb895793b0e65bb24d13720af633b48e6a55 Mon Sep 17 00:00:00 2001 From: ispik Date: Tue, 21 Apr 2026 17:01:35 +0300 Subject: [PATCH 1/3] feat: implement slowmode functionality with cooldown display Signed-off-by: ispik --- src/classes/Channel.ts | 18 ++++++++++++++++++ src/hydration/channel.ts | 3 +++ src/permissions/definitions.ts | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index db83df5e..198bf190 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -798,6 +798,24 @@ export class Channel { ); } + /** + * Get slowmode value for the channel + */ + get slowmode(): number { + return this.#collection.getUnderlyingObject(this.id).slowmode ?? 0; + } + + /** + * Set slowmode value for the channel + * @param slowmode Slowmode value in seconds, between 0 and 21600 + * @returns Updated channel data + */ + async setSlowmode(slowmode: number): Promise { + return await this.#collection.client.api.patch(`/channels/${this.id as ""}`, { + slowmode, + }); + } + /** * Join a call * @param node Target node diff --git a/src/hydration/channel.ts b/src/hydration/channel.ts index 9013fefe..9088f1f1 100644 --- a/src/hydration/channel.ts +++ b/src/hydration/channel.ts @@ -29,6 +29,7 @@ export type HydratedChannel = { defaultPermissions?: { a: bigint; d: bigint }; rolePermissions?: Record; nsfw: boolean; + slowmode: number; lastMessageId?: string; @@ -46,6 +47,7 @@ export const channelHydration: Hydrate, HydratedChannel> = { default_permissions: "defaultPermissions", role_permissions: "rolePermissions", last_message_id: "lastMessageId", + slowmode: "slowmode" }, functions: { id: (channel) => channel._id, @@ -76,6 +78,7 @@ export const channelHydration: Hydrate, HydratedChannel> = { ), nsfw: (channel) => channel.nsfw || false, lastMessageId: (channel) => channel.last_message_id!, + slowmode: (channel) => channel.slowmode ?? 0, voice: (channel) => !!channel.voice || channel.channel_type === "DirectMessage" || diff --git a/src/permissions/definitions.ts b/src/permissions/definitions.ts index 4ecf373d..c3853d44 100644 --- a/src/permissions/definitions.ts +++ b/src/permissions/definitions.ts @@ -67,6 +67,8 @@ export const Permission = { Masquerade: 2n ** 28n, /// React to messages with emoji React: 2n ** 29n, + /// Bypass slowmode + BypassSlowmode: 2n ** 39n, // * Voice permissions /// Connect to a voice channel From 217afce052a49cf76793601de977dba2847a33f8 Mon Sep 17 00:00:00 2001 From: ispik Date: Wed, 22 Apr 2026 09:53:24 +0300 Subject: [PATCH 2/3] refactor: format Signed-off-by: ispik --- src/classes/Channel.ts | 13 ++++++++----- src/hydration/channel.ts | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index 198bf190..7eb4cf95 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -807,13 +807,16 @@ export class Channel { /** * Set slowmode value for the channel - * @param slowmode Slowmode value in seconds, between 0 and 21600 - * @returns Updated channel data + * @param slowmode Slowmode value in seconds, between 0 and 21600 + * @returns Updated channel data */ async setSlowmode(slowmode: number): Promise { - return await this.#collection.client.api.patch(`/channels/${this.id as ""}`, { - slowmode, - }); + return await this.#collection.client.api.patch( + `/channels/${this.id as ""}`, + { + slowmode, + }, + ); } /** diff --git a/src/hydration/channel.ts b/src/hydration/channel.ts index 9088f1f1..d835afb8 100644 --- a/src/hydration/channel.ts +++ b/src/hydration/channel.ts @@ -47,7 +47,7 @@ export const channelHydration: Hydrate, HydratedChannel> = { default_permissions: "defaultPermissions", role_permissions: "rolePermissions", last_message_id: "lastMessageId", - slowmode: "slowmode" + slowmode: "slowmode", }, functions: { id: (channel) => channel._id, From c26fb9de737166883405db5dfe97da7a7bf59874 Mon Sep 17 00:00:00 2001 From: ispik Date: Mon, 27 Apr 2026 12:06:31 +0300 Subject: [PATCH 3/3] refactor: remove unnecessary function Signed-off-by: ispik --- src/classes/Channel.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index 7eb4cf95..00805a62 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -805,20 +805,6 @@ export class Channel { return this.#collection.getUnderlyingObject(this.id).slowmode ?? 0; } - /** - * Set slowmode value for the channel - * @param slowmode Slowmode value in seconds, between 0 and 21600 - * @returns Updated channel data - */ - async setSlowmode(slowmode: number): Promise { - return await this.#collection.client.api.patch( - `/channels/${this.id as ""}`, - { - slowmode, - }, - ); - } - /** * Join a call * @param node Target node