Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a channel tag for organizing and grouping channels. Tags can be created, updated, deleted, and associated with channels.

example
// Create a tag
const result = await Tag.createTag({ tagId: 'work', tagName: 'Work' });

// Get all tags
const tagsResult = await Tag.getTags();
if (tagsResult.isOk) {
tagsResult.data.forEach(tag => console.log(tag.tagName));
}

// Add channels to a tag (obtain a Tag instance first)
const tagResult = await Tag.getTag('work');
if (tagResult.isOk) {
await tagResult.data.addChannels([new DirectChannelIdentifier('user-123')]);
}

Hierarchy

  • Tag

Index

Methods

  • Creates a new tag.

    example
    const result = await Tag.createTag({ tagId: 'vip', tagName: 'VIP Channels' });
    if (result.isOk) {
    console.log('Tag created:', result.data.tagName);
    }

    Parameters

    Returns Promise<NCResult<Tag>>

    A promise resolving to the created Tag instance

  • Retrieves all tags.

    example
    const result = await Tag.getTags();
    if (result.isOk) {
    result.data.forEach(tag => {
    console.log(`${tag.tagName}: ${tag.channelCount} channels`);
    });
    }

    Returns Promise<NCResult<Tag[]>>

    A promise resolving to an array of Tag instances

  • Retrieves a specific tag by its ID.

    example
    const result = await Tag.getTag('vip');
    if (result.isOk) {
    console.log('Tag name:', result.data.tagName);
    }

    Parameters

    • tagId: string

      The unique tag ID

    Returns Promise<NCResult<Tag>>

    A promise resolving to the Tag instance

  • Deletes this tag.

    example
    await tag.delete();
    

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • update(tagName: string): Promise<NCResult<void>>
  • Updates the tag's display name.

    example
    await tag.update('New Tag Name');
    

    Parameters

    • tagName: string

      The new tag name

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Associates channels with this tag.

    example
    await tag.addChannels([
    new DirectChannelIdentifier('user-123'),
    new GroupChannelIdentifier('group-456'),
    ]);

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • Removes the association of channels from this tag.

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

    Parameters

    Returns Promise<NCResult<void>>

    A promise resolving to the operation result

  • getUnreadCount(containNoDisturb: boolean): Promise<NCResult<number>>
  • Gets the total unread message count for all channels associated with this tag.

    example
    const result = await tag.getUnreadCount(false);
    if (result.isOk) {
    console.log('Unread count:', result.data);
    }

    Parameters

    • containNoDisturb: boolean

      Whether to include muted channels in the count

    Returns Promise<NCResult<number>>

    A promise resolving to the total unread count

Accessors

  • get tagId(): string
  • The unique tag ID

    Returns string

  • get tagName(): string
  • The display name of the tag

    Returns string

Properties

timestamp: number = 0

The timestamp (ms) when the tag was created

channelCount: number = 0

The number of channels associated with this tag