ChannelGroupClient
ChannelGroupClient:
TypedEventEmitter<ChannelGroupEvents> &object
Type declaration
create()
Parameters
| Parameter | Type |
|---|---|
request | ChannelGroupCreateRequest |
Returns
Promise<ChannelGroup>
Example
import {
ChannelGroup,
ChannelGroupCreateRequest,
rootServer,
} from "@rootsdk/server-bot";
export async function createExample(): Promise<ChannelGroup> {
try {
// Set up the request
const request: ChannelGroupCreateRequest = {
name: "MyChannelGroupName",
accessRuleCreates: [],
};
// Call the API
const channelGroup: ChannelGroup =
await rootServer.community.channelGroups.create(request);
return channelGroup;
} catch (error) {
// Detect error
throw error;
}
}
delete()
Parameters
| Parameter | Type |
|---|---|
request | ChannelGroupDeleteRequest |
Returns
Promise<void>
Example
import {
ChannelGroupDeleteRequest,
ChannelGroupGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function deleteExample(
channelGroupId: ChannelGroupGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelGroupDeleteRequest = {
id: channelGroupId,
};
// Call the API
await rootServer.community.channelGroups.delete(request);
} catch (error) {
// Detect error
throw error;
}
}
edit()
Parameters
| Parameter | Type |
|---|---|
request | ChannelGroupEditRequest |
eventHandlers? | { channelGroup.created: ChannelGroupCreatedHandler; channelGroup.deleted: ChannelGroupDeletedHandler; } |
eventHandlers.channelGroup.created? | ChannelGroupCreatedHandler |
eventHandlers.channelGroup.deleted? | ChannelGroupDeletedHandler |
Returns
Promise<void>
Example
import {
ChannelGroup,
ChannelGroupEditRequest,
ChannelGroupGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function editExample(
channelGroupId: ChannelGroupGuid,
// events: BUG BUG BUG
): Promise<void> {
try {
// Set up the request
const request: ChannelGroupEditRequest = {
id: channelGroupId,
name: "MyChannelGroupName",
accessRuleUpdate: undefined,
};
// Call the API
await rootServer.community.channelGroups.edit(request);
} catch (error) {
// Detect error
throw error;
}
}
get()
Parameters
| Parameter | Type |
|---|---|
request | ChannelGroupGetRequest |
Returns
Promise<ChannelGroup>
Example
import {
ChannelGroup,
ChannelGroupGetRequest,
ChannelGroupGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function getExample(
channelGroupId: ChannelGroupGuid,
): Promise<ChannelGroup> {
try {
// Set up the request
const request: ChannelGroupGetRequest = {
id: channelGroupId,
};
// Call the API
const channelGroup: ChannelGroup =
await rootServer.community.channelGroups.get(request);
return channelGroup;
} catch (error) {
// Detect error
throw error;
}
}
list()
Returns
Promise<ChannelGroup[]>
Example
import {
ChannelListRequest,
ChannelGroup,
rootServer,
} from "@rootsdk/server-bot";
export async function listExample(): Promise<ChannelGroup[]> {
try {
// Call the API
const channelGroups: ChannelGroup[] =
await rootServer.community.channelGroups.list();
return channelGroups;
} catch (error) {
// Detect error
throw error;
}
}
move()
Parameters
| Parameter | Type |
|---|---|
request | ChannelGroupMoveRequest |
Returns
Promise<void>
Example
import {
ChannelGroup,
ChannelGroupMoveRequest,
ChannelGroupGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function moveExample(
channelGroupId: ChannelGroupGuid,
beforeChannelGroupId: ChannelGroupGuid,
// events: BUG BUG BUG
): Promise<void> {
try {
// Set up the request
const request: ChannelGroupMoveRequest = {
id: channelGroupId,
beforeChannelGroupId: beforeChannelGroupId,
};
// Call the API
await rootServer.community.channelGroups.move(request);
} catch (error) {
// Detect error
throw error;
}
}