Skip to main content

Delete a channel

Delete channels from the user's channel list. Deleting a channel removes the channel and its messages from the current user's view. Other participants are not affected.

Delete a single channel

Call channel.delete() on a channel instance:

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

const channel = new DirectChannel('<target-user-id>');
const { code } = await channel.delete();
if (code === 0) {
console.log('Channel deleted');
} else {
console.log('Delete failed. Code:', code);
}

Delete multiple channels

Use BaseChannel.deleteChannels with an array of channel identifiers:

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

const { code } = await BaseChannel.deleteChannels([
new DirectChannel('user1').identifier,
new GroupChannel('group1').identifier,
]);
if (code === 0) {
console.log('Channels deleted');
}
warning

Deleting a channel removes it and its message history from your view. This action cannot be undone locally. Messages are not deleted from the server-side history.