CommunitiesUSER-ONLY
User Walkthrough 9 of 18
User clients can organize related chats into communities.
Creating a Community
Use createCommunity with a name and the identifier of its first chat.
const community = await client.createCommunity("Project", chatId, {
description: "Project discussions",
});
Listing Communities
Use getJoinedCommunities to get the account’s communities as CommunityP objects.
const communities = await client.getJoinedCommunities();
for (const community of communities) {
console.log(community.id, community.name);
}
Getting a Community
Use getCommunity to get a Community, including its chats.
const community = await client.getCommunity(communityId);
for (const { chat } of community.chats) {
console.log(chat.id, chat.type);
}
Managing Chats
Use addChatToCommunity and removeChatFromCommunity to manage a community’s chats.
await client.addChatToCommunity(communityId, chatId);
await client.removeChatFromCommunity(communityId, chatId);
Changing the Display
Choose whether the community appears as one chat or as separate chats.
await client.showCommunityAsOneChat(communityId);
await client.showCommunityAsDifferentChats(communityId);
Deleting a Community
Use deleteCommunity with the community’s identifier.
await client.deleteCommunity(communityId);