Skip to main content

ChannelWebRtcClient

ChannelWebRtcClient = TypedEventEmitter<ChannelWebRtcEvents> & object

Service client for monitoring and moderating voice channel participants. Provides methods to list active participants, kick users from voice, and apply server-side mute or deafen states.

This client does not provide access to audio content. Apps and bots can observe participation events and enforce policies based on observable state, but cannot listen to or broadcast audio.

Access this client via rootServer.community.channelWebRtcs.

Type Declaration

kick()

kick(request: ChannelWebRtcKickRequest): Promise<void>

Removes a participant from a voice channel. The user can rejoin unless other restrictions apply.

Parameters

ParameterTypeDescription
requestChannelWebRtcKickRequestIdentifies the channel and user to kick.

Returns

Promise<void>

A promise that resolves when the kick completes.

Throws

RootApiException with errorCode set to NoPermissionToKick if missing required permissions, or NotFound if the user is not in the voice channel.

Example

import {
ChannelWebRtcMuteAndDeafenRequest,
ChannelGuid,
UserGuid,
DeviceGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function kickExample(
channelId: ChannelGuid,
userId: UserGuid,
deviceId?: DeviceGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelWebRtcKickRequest = {
channelId: channelId,
userId: userId,
deviceId: deviceId,
};

// Call the API
await rootServer.community.channelWebRtcs.kick(request);
} catch (error) {
// Detect error
throw error;
}
}

list()

list(request: ChannelWebRtcListRequest): Promise<ChannelWebRtcListResponse>

Lists all participants currently in a voice channel. If no voice session is active, returns an empty array rather than throwing an error.

Parameters

ParameterTypeDescription
requestChannelWebRtcListRequestIdentifies the voice channel to query.

Returns

Promise<ChannelWebRtcListResponse>

A promise that resolves to a ChannelWebRtcListResponse containing the session creation time and array of participants. When no voice session is active, members is an empty array.

Throws

RootApiException with errorCode set to NoPermissionToRead if missing required permissions.

Example

import {
ChannelWebRtcListRequest,
ChannelWebRtcListResponse,
ChannelGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function listExample(
channelId: ChannelGuid,
): Promise<ChannelWebRtcListResponse> {
try {
// Set up the request
const request: ChannelWebRtcListRequest = {
channelId: channelId,
};

// Call the API
const response: ChannelWebRtcListResponse =
await rootServer.community.channelWebRtcs.list(request);

return response;
} catch (error) {
// Detect error
throw error;
}
}

setMuteAndDeafenOther()

setMuteAndDeafenOther(request: ChannelWebRtcSetMuteAndDeafenOtherRequest): Promise<void>

Applies server-side mute or deafen state to a participant. Server mutes cannot be overridden by the user until removed by an app or moderator.

Parameters

ParameterTypeDescription
requestChannelWebRtcSetMuteAndDeafenOtherRequestIdentifies the channel, user, and desired mute/deafen state.

Returns

Promise<void>

A promise that resolves when the state change completes.

Throws

RootApiException with errorCode set to NoPermissionToMute if missing required permissions, or NotFound if the user is not in the voice channel.

Example

import {
ChannelWebRtcSetMuteAndDeafenOtherRequest,
ChannelGuid,
UserGuid,
rootServer,
} from "@rootsdk/server-bot";

export async function setMuteAndDeafenOtherExample(
channelId: ChannelGuid,
userId: UserGuid,
isMuted?: boolean,
isDeafened?: boolean,
): Promise<void> {
try {
// Set up the request
const request: ChannelWebRtcSetMuteAndDeafenOtherRequest = {
channelId: channelId,
userId: userId,
isMuted: isMuted,
isDeafened: isDeafened,
};

// Call the API
await rootServer.community.channelWebRtcs.setMuteAndDeafenOther(request);
} catch (error) {
// Detect error
throw error;
}
}