Skip to main content

Set channel DND

Set do-not-disturb (DND) for a specific channel. When DND is enabled, the user does not receive push notifications for new messages in that channel.

Set DND for a channel

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

const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.setNoDisturbLevel(ChannelNoDisturbLevel.MUTED);
if (code === 0) {
console.log('DND set successfully');
}

DND levels

Enum valueNumeric valueDescription
ChannelNoDisturbLevel.ALL_MESSAGE-1Receive notifications for all messages
ChannelNoDisturbLevel.DEFAULT0Follow the global or app-level DND configuration
ChannelNoDisturbLevel.MENTION1Only notify for @mention messages (all mention types)
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 for a channel

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

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

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

const channel = channels?.find(ch => ch.channelId === '<target-user-id>') as DirectChannel | undefined;
if (channel) {
console.log('Current DND level:', channel.noDisturbLevel);
}

Remove DND for a channel

Reset to the default level:

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

const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.setNoDisturbLevel(ChannelNoDisturbLevel.DEFAULT);
if (code === 0) {
console.log('DND removed');
}
tip
  • DND settings are synced across devices when multi-device sync is enabled.
  • For community channels, you can also set DND at the subchannel level. See [Set community subchannel DND](../community channel/do-not-disturb.md).