mirror of
https://github.com/stoatchat/javascript-client-sdk.git
synced 2026-07-19 17:13:31 -04:00
feat: hydrate slowmode into channels and add the new permission (#151)
* feat: implement slowmode functionality with cooldown display Signed-off-by: ispik <ispik@ispik.dev> * refactor: format Signed-off-by: ispik <ispik@ispik.dev> * refactor: remove unnecessary function Signed-off-by: ispik <ispik@ispik.dev> --------- Signed-off-by: ispik <ispik@ispik.dev>
This commit is contained in:
@@ -798,6 +798,13 @@ export class Channel {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get slowmode value for the channel
|
||||
*/
|
||||
get slowmode(): number {
|
||||
return this.#collection.getUnderlyingObject(this.id).slowmode ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a call
|
||||
* @param node Target node
|
||||
|
||||
@@ -29,6 +29,7 @@ export type HydratedChannel = {
|
||||
defaultPermissions?: { a: bigint; d: bigint };
|
||||
rolePermissions?: Record<string, { a: bigint; d: bigint }>;
|
||||
nsfw: boolean;
|
||||
slowmode: number;
|
||||
|
||||
lastMessageId?: string;
|
||||
|
||||
@@ -46,6 +47,7 @@ export const channelHydration: Hydrate<Merge<APIChannel>, 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<Merge<APIChannel>, 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" ||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user