Skip to main content

ChannelMessageClient

ChannelMessageClient: TypedEventEmitter<ChannelMessageEvents> & object

Type declaration

create()

Parameters

ParameterType
requestChannelMessageCreateRequest

Returns

Promise<ChannelMessage>

Example

import {
ChannelGuid,
ChannelMessage,
ChannelMessageCreateRequest,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageDeleteRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessage,
ChannelMessageDeleteRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageEditRequest

Returns

Promise<ChannelMessage>

Example

import {
ChannelGuid,
MessageGuid,
ChannelMessage,
ChannelMessageEditRequest,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageFlagRequest

Returns

Promise<void>

get()

Parameters

ParameterType
requestChannelMessageGetRequest

Returns

Promise<ChannelMessage>

list()

Parameters

ParameterType
requestChannelMessageListRequest

Returns

Promise<ChannelMessageListResponse>

Example

import {
ChannelMessageListResponse,
ChannelGuid,
ChannelMessageListRequest,
MessageDirectionTake,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessagePinCreateRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessagePinCreateRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessagePinDeleteRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessagePinDeleteRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessagePinListRequest

Returns

Promise<ChannelMessagePinListResponse>

Example

import {
ChannelGuid,
ChannelMessagePinListRequest,
ChannelMessagePinListResponse,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageReactionCreateRequest

Returns

Promise<ChannelMessageReaction>

Example

import {
ChannelGuid,
ChannelMessageReactionCreateRequest,
ChannelMessageReaction,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageReactionDeleteRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessageReactionDeleteRequest,
ChannelMessageReaction,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageSetTypingIndicatorRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessageSetTypingIndicatorRequest,
rootServer,
} from "@rootsdk/server-app";

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

ParameterType
requestChannelMessageSetViewTimeRequest

Returns

Promise<void>

Example

import {
ChannelGuid,
ChannelMessageSetViewTimeRequest,
MessageGuid,
rootServer,
} from "@rootsdk/server-app";

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;
}
}