Skip to main content

Channels API

The channels API reads, selects, creates, renames, and removes server channels.

Required Capabilities

MethodCapability
channels.list()channels.read
channels.select(channelId)channels.read
channels.addAudioChannel(request)channels.manage
channels.addVideoChannel(request)channels.manage
channels.rename(channelId, name)channels.manage
channels.remove(channelId)channels.manage

List Channels

export function activate(context) {
const channels = context.api.channels.list();

context.api.logger.info('Channels', channels.map((channel) => ({
id: channel.id,
name: channel.name,
type: channel.type
})));
}

Example channel list:

[
{ "id": "general", "name": "general", "type": "text", "position": 0 },
{ "id": "support", "name": "support", "type": "text", "position": 1 },
{ "id": "lobby", "name": "Lobby", "type": "audio", "position": 10 }
]

Select a Channel

export function activate(context) {
context.api.channels.select('support');
}

Add a Voice Channel

export function activate(context) {
context.api.channels.addAudioChannel({
id: 'raid-voice',
name: 'Raid Voice',
position: 20
});
}

Add a Video Channel Section

export function activate(context) {
context.api.channels.addVideoChannel({
id: 'watch-party-video',
name: 'Watch Party',
position: 30
});
}

Rename and Remove

export function activate(context) {
context.api.channels.rename('raid-voice', 'Raid Voice - Tonight');
context.api.channels.remove('old-event-room');
}

Channel creation, rename, and removal should be user-confirmed because they change the shared server structure.