CommunitiesUSER-ONLY
User Walkthrough 3 of 50
Users can organize related chats into communities.
Creating a Community
createCommunity accepts a name and the identifier of its first chat.
const community = await client.createCommunity("Project", chatId, {
description: "Project discussions",
});
Listing Communities
With getJoinedCommunities, you can 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
getCommunity returns a Community, including its chats.
const community = await client.getCommunity(communityId);
for (const { chat } of community.chats) {
console.log(chat.id, chat.type);
}
getCommunityP returns only the community’s peer representation.
Managing Chats
To manage a community’s chats, call addChatToCommunity and removeChatFromCommunity.
await client.addChatToCommunity(communityId, chatId);
await client.removeChatFromCommunity(communityId, chatId);
Changing the Display
The community can appear as one chat or as separate chats.
await client.showCommunityAsOneChat(communityId);
await client.showCommunityAsDifferentChats(communityId);
Deleting a Community
deleteCommunity deletes the community identified by its argument.
await client.deleteCommunity(communityId);