Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a group channel. Provides group-specific operations such as creating groups, managing members, roles, invites, and applications.

example
// Create a group
await GroupChannel.createGroup({
groupId: 'group-001',
groupName: 'My Group',
inviteeUserIds: ['user-1', 'user-2'],
});

// Send a message in a group
const group = new GroupChannel('group-001');
const params = new SendTextMessageParams({ text: 'Hello group!' });
await group.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

  • Creates a new group.

    example
    await GroupChannel.createGroup({
    groupId: 'group-001',
    groupName: 'My Group',
    inviteeUserIds: ['user-1'],
    });

    Parameters

    Returns Promise<NCResult<ICreateGroupFail>>

    A promise resolving to any failure info (e.g. users that failed to be invited)

  • Updates this group's information (name, portrait, etc.).

    example
    await group.updateInfo({ groupName: 'New name' });
    

    Parameters

    Returns Promise<NCResult<IErrorKeys>>

    A promise resolving to error keys if any fields failed

  • Gets group information for specified group IDs.

    example
    const result = await GroupChannel.getGroupsInfo(['group-001', 'group-002']);
    

    Parameters

    • groupIds: string[]

      The group IDs to query

    Returns Promise<NCResult<GroupInfo[]>>

    A promise resolving to the group info list

  • Gets information for groups the current user has joined.

    example
    const result = await GroupChannel.getJoinedGroups(['group-001']);
    

    Parameters

    • groupIds: string[]

      The group IDs to filter

    Returns Promise<NCResult<GroupInfo[]>>

    A promise resolving to the joined group info list

  • Kicks members from this group.

    example
    await group.kickMembers({ userIds: ['user-1', 'user-2'] });
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Leaves this group.

    example
    await group.leave();
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Dismisses (dissolves) this group. Only the group owner can perform this operation.

    example
    await group.dismiss();
    

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Joins this group.

    example
    const result = await group.join();
    

    Returns Promise<NCResult<ProcessCode>>

    A promise resolving to the process code

  • Transfers group ownership to another user.

    example
    await group.transferOwner({ newOwnerId: 'user-999' });
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • addManagers(userIds: string[]): Promise<NCResult<void>>
  • Adds group managers (admin role).

    example
    await group.addManagers(['user-1', 'user-2']);
    

    Parameters

    • userIds: string[]

      The user IDs to promote to manager

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • removeManagers(userIds: string[]): Promise<NCResult<void>>
  • Removes group managers (demotes from admin role).

    example
    await group.removeManagers(['user-1']);
    

    Parameters

    • userIds: string[]

      The user IDs to demote

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Creates a paginated query for group members filtered by role.

    example
    import { GroupMemberRole } from '@nexconn/chat';

    const query = GroupChannel.createGroupMembersByRoleQuery({
    groupId: 'group-001',
    role: GroupMemberRole.MANAGER,
    pageSize: 20,
    });
    const page = await query.loadNextPage();

    Parameters

    Returns GroupMembersByRoleQuery

  • Gets group member information for the specified user IDs.

    example
    const result = await group.getMembers(['user-1', 'user-2']);
    

    Parameters

    • userIds: string[]

      The user IDs to query

    Returns Promise<NCResult<GroupMemberInfo[]>>

    A promise resolving to the member info list

  • Sets a member's info (nickname, extra) in this group.

    example
    await group.setMemberInfo({
    userId: 'user-1',
    nickname: 'Alice',
    });

    Parameters

    Returns Promise<NCResult<IErrorKeys>>

    A promise resolving to error keys if any fields failed

  • Invites users to this group.

    example
    const result = await group.inviteUsers(['user-3', 'user-4']);
    

    Parameters

    • userIds: string[]

      User IDs to invite

    Returns Promise<NCResult<ProcessCode>>

    A promise resolving to the process code

  • acceptInvite(inviterId: string): Promise<NCResult<void>>
  • Accepts a group invitation.

    example
    await group.acceptInvite('inviter-user-id');
    

    Parameters

    • inviterId: string

      The user ID who sent the invitation

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Refuses a group invitation.

    example
    await group.refuseInvite({ inviterId: 'inviter-user-id' });
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Accepts a group join application.

    example
    const result = await group.acceptApplication({ applicantId: 'user-applicant' });
    

    Parameters

    Returns Promise<NCResult<ProcessCode>>

    A promise resolving to the process code

  • Refuses a group join application.

    example
    await group.refuseApplication({ applicantId: 'user-applicant' });
    

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Creates a paginated query for group applications.

    example
    import { GroupApplicationStatus } from '@nexconn/chat';

    const query = GroupChannel.createGroupApplicationsQuery({
    pageSize: 20,
    status: [GroupApplicationStatus.MANAGER_UNHANDLED],
    });
    const page = await query.loadNextPage();

    Parameters

    Returns GroupApplicationsQuery

  • Creates a paginated query for joined groups filtered by the user's role.

    example
    import { GroupMemberRole } from '@nexconn/chat';

    const query = GroupChannel.createJoinedGroupsByRoleQuery({
    role: GroupMemberRole.MANAGER,
    pageSize: 20,
    });
    const page = await query.loadNextPage();

    Parameters

    Returns JoinedGroupsByRoleQuery

  • addFavorites(userIds: string[]): Promise<NCResult<void>>
  • Adds users to the group favorites list.

    example
    await group.addFavorites(['user-1']);
    

    Parameters

    • userIds: string[]

      User IDs to add as favorites

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • removeFavorites(userIds: string[]): Promise<NCResult<void>>
  • Removes users from the group favorites list.

    example
    await group.removeFavorites(['user-1']);
    

    Parameters

    • userIds: string[]

      User IDs to remove from favorites

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Gets the group favorites list.

    example
    const result = await group.getFavorites();
    

    Returns Promise<NCResult<FavoritesUserInfo[]>>

    A promise resolving to the favorites info list

Accessors

  • The channel identifier

    Returns ChannelIdentifier

  • 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

Constructors

  • Parameters

    • channelId: string

      The unique group channel ID

    Returns GroupChannel