Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a sub-channel within a community (ultra group).

example
const sub = new CommunitySubChannel('community-001', 'sub-001');
const params = new SendTextMessageParams({ text: 'Hello sub-channel' });
await sub.sendMessage(params);

Hierarchy

Index

Methods

  • Gets channels that have unread messages.

    example
    const result = await BaseChannel.getUnreadChannels([ChannelType.DIRECT, ChannelType.GROUP]);
    

    Parameters

    Returns Promise<NCResult<BaseChannel[]>>

    A promise resolving to the list of channels with unread messages

  • Gets pinned (top) channels filtered by channel types.

    example
    const result = await BaseChannel.getPinnedChannels([ChannelType.DIRECT, ChannelType.GROUP]);
    

    Parameters

    Returns Promise<NCResult<BaseChannel[]>>

    A promise resolving to the list of pinned channels

  • Deletes channels by their identifiers.

    example
    await BaseChannel.deleteChannels([new DirectChannelIdentifier('user-123')]);
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Sets the do-not-disturb level for all channels of a specific type.

    example
    await BaseChannel.setChannelTypeNoDisturbLevel({
    channelType: ChannelType.GROUP,
    level: ChannelNoDisturbLevel.MUTED,
    });

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • getTotalUnreadCount(): Promise<NCResult<number>>
  • Gets the total unread message count across all channels.

    example
    const result = await BaseChannel.getTotalUnreadCount();
    if (result.isOk) {
    console.log('Total unread:', result.data);
    }

    Returns Promise<NCResult<number>>

    A promise resolving to the total unread count

  • Gets the total unread message count filtered by do-not-disturb levels and channel types.

    example
    const r = await BaseChannel.getChannelsUnreadCountByNoDisturbLevel({
    channelTypes: [ChannelType.DIRECT],
    levels: [ChannelNoDisturbLevel.DEFAULT],
    });

    Parameters

    Returns Promise<NCResult<number>>

    A promise resolving to the filtered unread count

  • Pins this channel to the top of the channel list.

    example
    await channel.pin();
    

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Unpins this channel from the top of the channel list.

    example
    await channel.unpin();
    

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Deletes this channel.

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • deleteTags(tagIds: string[]): Promise<NCResult<void>>
  • Removes tags from this channel.

    Parameters

    • tagIds: string[]

      The tag IDs to remove

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets all tags associated with this channel.

    Returns Promise<NCResult<Tag[]>>

    A promise resolving to the list of tags

  • Sets the do-not-disturb level for this channel.

    example
    await channel.setNoDisturbLevel(ChannelNoDisturbLevel.MUTED);
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • clearUnreadCount(): Promise<NCResult<void>>
  • saveDraft(draft: string): Promise<NCResult<void>>
  • Saves a draft text for this channel.

    Parameters

    • draft: string

      The draft text to save

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Clears the saved draft text for this channel.

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Deletes messages for the current user only (messages remain visible to others).

    Parameters

    • messages: Message<any>[]

      The messages to delete

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets messages by their server-side message IDs.

    example
    const result = await BaseChannel.getMessagesByIds({
    channelIdentifier: new DirectChannelIdentifier('user-123'),
    messageIds: ['msg-1', 'msg-2'],
    });
    if (result.isOk) {
    const msg = result.data['msg-1'];
    }

    Parameters

    Returns Promise<NCResult<Record<string, undefined | Message<any>>>>

    A promise resolving to a map of message ID to message (or undefined if not found)

  • Deletes (recalls) a message for all users in the channel.

    example
    await channel.deleteMessageForAll(sentMessage);
    

    Parameters

    • message: Message<any>

      The message to recall

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Sends a message in this channel.

    example
    const params = new SendTextMessageParams({ text: 'Hello!' });
    const result = await channel.sendMessage(params);
    if (result.isOk) {
    console.log('Sent message ID:', result.data.messageId);
    }

    Type Parameters

    • T extends Record<string, any>

      The type of the message content

    Parameters

    Returns Promise<NCResult<Message<T>>>

    A promise resolving to the sent message

  • Sends a media message (image, file, voice, etc.) that requires file upload.

    example
    const result = await Message.createSendImageMessageParams(imageFile);
    if (result.isOk) {
    const sentResult = await channel.sendMediaMessage(result.data);
    }

    Type Parameters

    • T extends Record<string, any>

      The type of the message content

    Parameters

    Returns Promise<NCResult<Message<T>>>

    A promise resolving to the sent message

  • sendReadReceiptResponse(messageIds: string[]): Promise<NCResult<void>>
  • Sends read receipt responses for the specified messages.

    example
    await channel.sendReadReceiptResponse(['msg-1', 'msg-2']);
    

    Parameters

    • messageIds: string[]

      The message IDs to acknowledge as read

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Modifies (edits) a sent message's content.

    example
    await BaseChannel.modifyMessage({
    channelIdentifier: originalMessage.channelIdentifier,
    messageId: originalMessage.messageId,
    content: { text: 'Updated text' },
    });

    Type Parameters

    • T extends Record<string, any>

      The type of the message content

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

Accessors

  • get channelId(): string
  • The channel ID

    Returns string

  • The channel type

    Returns ChannelType

  • The do-not-disturb level for this channel

    Returns ChannelNoDisturbLevel

  • get isPinned(): boolean
  • Whether this channel is pinned (stuck to top)

    Returns boolean

  • get unreadCount(): number
  • The unread message count for this channel

    Returns number

  • get operationTime(): number
  • The last operation timestamp (ms) on this channel

    Returns number

  • get draft(): string
  • The saved draft text for this channel

    Returns string

  • get latestMessage(): null | Message<any>
  • The latest message in this channel, or null if none

    Returns null | Message<any>

  • The translate strategy applied to this channel

    Returns TranslateStrategy

  • get includeRobot(): boolean
  • Whether this channel includes robot/bot users

    Returns boolean

  • get subChannelId(): string
  • The sub-channel ID within the community

    Returns string

Constructors

  • Parameters

    • channelId: string

      Parent community channel ID

    • subChannelId: string

      Sub-channel ID within the community

    Returns CommunitySubChannel