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 value | Numeric value | Description |
|---|---|---|
ChannelNoDisturbLevel.ALL_MESSAGE | -1 | Receive notifications for all messages |
ChannelNoDisturbLevel.DEFAULT | 0 | Follow the community/subchannel default or app-level setting |
ChannelNoDisturbLevel.MENTION | 1 | Only notify for @mention messages |
ChannelNoDisturbLevel.MENTION_USERS | 2 | Only notify when specific users are @mentioned |
ChannelNoDisturbLevel.MENTION_ALL | 4 | Only notify when @all is used |
ChannelNoDisturbLevel.MUTED | 5 | Mute 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.