Files
Toju/docs-site/docs/plugin-development/api/channels.md
Myx 0a714428f6 docs: improve doucmentation
improve doucmentation and fix small store changes
2026-04-30 01:16:48 +02:00

1.8 KiB

sidebar_position
sidebar_position
5

Channels API

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

Required Capabilities

Method Capability
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.