ChannelMessageClient
ChannelMessageClient:
TypedEventEmitter<ChannelMessageEvents> &object
Type declaration
create()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageCreateRequest |
Returns
Promise<ChannelMessage>
Example
import {
ChannelGuid,
ChannelMessage,
ChannelMessageCreateRequest,
rootServer,
} from "@rootsdk/server-bot";
export async function createExample(
channelId: ChannelGuid,
): Promise<ChannelMessage> {
try {
// Set up the request
const request: ChannelMessageCreateRequest = {
channelId: channelId,
content: "Example Message",
attachmentTokenUris: undefined,
};
// Call the API
const message: ChannelMessage =
await rootServer.community.channelMessages.create(request);
return message;
} catch (error) {
// Detect error
throw error;
}
}
delete()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageDeleteRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessage,
ChannelMessageDeleteRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function deleteExample(
channelId: ChannelGuid,
messageId: MessageGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessageDeleteRequest = {
id: messageId,
channelId: channelId,
};
// Call the API
await rootServer.community.channelMessages.delete(request);
} catch (error) {
// Detect error
throw error;
}
}
edit()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageEditRequest |
Returns
Promise<ChannelMessage>
Example
import {
ChannelGuid,
MessageGuid,
ChannelMessage,
ChannelMessageEditRequest,
rootServer,
} from "@rootsdk/server-bot";
export async function editExample(
messageId: MessageGuid,
channelId: ChannelGuid,
): Promise<ChannelMessage> {
try {
// Set up the request
const request: ChannelMessageEditRequest = {
id: messageId,
channelId: channelId,
content: "Edited Example Message",
uris: undefined,
};
// Call the API
const message: ChannelMessage =
await rootServer.community.channelMessages.edit(request);
return message;
} catch (error) {
// Detect error
throw error;
}
}
flag()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageFlagRequest |
Returns
Promise<void>
get()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageGetRequest |
Returns
Promise<ChannelMessage>
list()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageListRequest |
Returns
Promise<ChannelMessageListResponse>
Example
import {
ChannelMessageListResponse,
ChannelGuid,
ChannelMessageListRequest,
MessageDirectionTake,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function listExample(
channelId: ChannelGuid,
): Promise<ChannelMessageListResponse> {
try {
// Set up the request
const request: ChannelMessageListRequest = {
channelId: channelId,
messageDirectionTake: MessageDirectionTake.Both,
dateAt: new Date(),
};
// Call the API
const messages: ChannelMessageListResponse =
await rootServer.community.channelMessages.list(request);
return messages;
} catch (error) {
// Detect error
throw error;
}
}
pinCreate()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessagePinCreateRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessagePinCreateRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function pinCreateExample(
channelId: ChannelGuid,
messageId: MessageGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessagePinCreateRequest = {
channelId: channelId,
messageId: messageId,
};
// Call the API
await rootServer.community.channelMessages.pinCreate(request);
} catch (error) {
// Detect error
throw error;
}
}
pinDelete()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessagePinDeleteRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessagePinDeleteRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function pinDeleteExample(
channelId: ChannelGuid,
messageId: MessageGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessagePinDeleteRequest = {
channelId: channelId,
messageId: messageId,
};
// Call the API
await rootServer.community.channelMessages.pinDelete(request);
} catch (error) {
// Detect error
throw error;
}
}
pinList()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessagePinListRequest |
Returns
Promise<ChannelMessagePinListResponse>
Example
import {
ChannelGuid,
ChannelMessagePinListRequest,
ChannelMessagePinListResponse,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function pinListExample(
channelId: ChannelGuid,
): Promise<ChannelMessagePinListResponse> {
try {
// Set up the request
const request: ChannelMessagePinListRequest = {
channelId: channelId,
};
// Call the API
const pinList = await rootServer.community.channelMessages.pinList(request);
return pinList;
} catch (error) {
// Detect error
throw error;
}
}
reactionCreate()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageReactionCreateRequest |
Returns
Promise<ChannelMessageReaction>
Example
import {
ChannelGuid,
ChannelMessageReactionCreateRequest,
ChannelMessageReaction,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function reactionCreateExample(
channelId: ChannelGuid,
messageId: MessageGuid,
shortcode: string,
): Promise<ChannelMessageReaction> {
try {
// Set up the request
const request: ChannelMessageReactionCreateRequest = {
channelId: channelId,
messageId: messageId,
shortcode: shortcode,
};
// Call the API
const reaction =
await rootServer.community.channelMessages.reactionCreate(request);
return reaction;
} catch (error) {
// Detect error
throw error;
}
}
reactionDelete()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageReactionDeleteRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessageReactionDeleteRequest,
ChannelMessageReaction,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function reactionDeleteExample(
channelId: ChannelGuid,
messageId: MessageGuid,
shortcode: string,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessageReactionDeleteRequest = {
channelId: channelId,
messageId: messageId,
shortcode: shortcode,
};
// Call the API
await rootServer.community.channelMessages.reactionDelete(request);
} catch (error) {
// Detect error
throw error;
}
}
setTypingIndicator()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageSetTypingIndicatorRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessageSetTypingIndicatorRequest,
rootServer,
} from "@rootsdk/server-bot";
export async function setTypingIndicatorExample(
channelId: ChannelGuid,
isTyping: boolean,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessageSetTypingIndicatorRequest = {
channelId: channelId,
isTyping: isTyping,
};
// Call the API
await rootServer.community.channelMessages.setTypingIndicator(request);
} catch (error) {
// Detect error
throw error;
}
}
setViewTime()
Parameters
| Parameter | Type |
|---|---|
request | ChannelMessageSetViewTimeRequest |
Returns
Promise<void>
Example
import {
ChannelGuid,
ChannelMessageSetViewTimeRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-bot";
export async function setViewTimeExample(
channelId: ChannelGuid,
): Promise<void> {
try {
// Set up the request
const request: ChannelMessageSetViewTimeRequest = {
channelId: channelId,
};
// Call the API
await rootServer.community.channelMessages.setViewTime(request);
} catch (error) {
// Detect error
throw error;
}
}