Skip to main content

Set community subchannel DND

Set do-not-disturb (DND) for a specific community channel or subchannel on a per-user basis.

Set DND for a community channel

TypeScript
import { CommunityChannel, ChannelNoDisturbLevel } from '@nexconn/chat';

const community = new CommunityChannel('<communityId>');
const { code } = await community.setNoDisturbLevel(ChannelNoDisturbLevel.MUTED);
if (code === 0) {
console.log('DND set for community channel');
}

Set DND for a community subchannel

TypeScript
import { CommunitySubChannel, ChannelNoDisturbLevel } from '@nexconn/chat';

const channel = new CommunitySubChannel('<communityId>', '<subChannelId>');
const { code } = await channel.setNoDisturbLevel(ChannelNoDisturbLevel.MENTION);
if (code === 0) {
console.log('DND set for subchannel');
}

DND levels

Enum valueNumeric valueDescription
ChannelNoDisturbLevel.ALL_MESSAGE-1Receive notifications for all messages
ChannelNoDisturbLevel.DEFAULT0Follow the community/subchannel default or app-level setting
ChannelNoDisturbLevel.MENTION1Only notify for @mention messages
ChannelNoDisturbLevel.MENTION_USERS2Only notify when specific users are @mentioned
ChannelNoDisturbLevel.MENTION_ALL4Only notify when @all is used
ChannelNoDisturbLevel.MUTED5Mute all notifications

Get the DND setting

The current DND level is available as the noDisturbLevel property on the channel object (populated after fetching the channel list):

TypeScript
import { BaseChannel } from '@nexconn/chat';

const query = BaseChannel.createChannelsQuery({ pageSize: 20 });
const { data: channels } = await query.loadNextPage();

const channel = channels?.find(ch => ch.channelId === '<subChannelId>');
if (channel) {
console.log('Current DND level:', channel.noDisturbLevel);
}
info

User-level DND settings take priority over the community/subchannel default DND configuration. See Do not disturb overview for the full priority chain.