Guides

Chat AdministrationUSER-ONLY

User Walkthrough 34 of 50

Users can create chats and manage administrative settings.

Creating Chats

createGroup, createSupergroup, and createChannel create their respective chat types.

const group = await client.createGroup("Project");
const supergroup = await client.createSupergroup("Community");
const channel = await client.createChannel("Announcements");

Deleting a Chat

A chat owned by the account can be deleted with deleteChat.

await client.deleteChat(group.id);

Joining Chats

joinChat joins a public chat, while joinChatByInviteLink follows an invite. resolveInviteLink inspects the invite beforehand.

const resolved = await client.resolveInviteLink(inviteLink);
await client.joinChat(chatId);
await client.joinChatByInviteLink(inviteLink);

History and Visibility

History visibility for new members is controlled by enableChatHistoryForNewMembers and disableChatHistoryForNewMembers.

Member-list visibility is controlled by showMemberList and hideMemberList. Content sharing has matching enableSharing and disableSharing methods.

await client.enableChatHistoryForNewMembers(chatId);
await client.showMemberList(chatId);
await client.enableSharing(chatId);

Channel Settings

Post signatures are controlled by enableSignatures and disableSignatures. Select the default sender with setDefaultSendAs.

getDiscussionChatSuggestions returns possible discussion chats; setDiscussionChat links the selected one.

await client.enableSignatures(channelId);
await client.setDefaultSendAs(chatId, sendAsId);
const suggestions = await client.getDiscussionChatSuggestions();
await client.setDiscussionChat(channelId, discussionChatId);

Read State

A chat’s read state is updated by markChatAsRead, markChatAsUnread, and markAllMentionsAsRead.

await client.markChatAsRead(chatId);
await client.markChatAsUnread(chatId);
await client.markAllMentionsAsRead(chatId);

Ownership

After meeting Telegram’s security requirements, transfer ownership with transferChatOwnership.

await client.transferChatOwnership(chatId, userId, password);