mtcute/packages/client/src/methods/invite-links/revoke-invite-link.ts
teidesu ec736f8590 some changes
i've been wanting to name a commit like this for my entire life, lol. seriously though, a lot has changed:
 - extracted TL-related stuff to `@mtcute/tl-utils` and `@mtcute/tl-runtime`, rewrote codegen in TS
 - updated to layer 134, moved to int64 identifiers
 - rewritten networking (mtproto), rewritten updates handling
 - *lots* of refactoring

 still a very early version though, there are a lot of improvements to be made, but at least it runs, lol

 also tl-reference will not be updated anytime soon because i want to rewrite it
2021-11-23 00:03:59 +03:00

35 lines
972 B
TypeScript

import { TelegramClient } from '../../client'
import { ChatInviteLink, InputPeerLike, PeersIndex } from '../../types'
/**
* Revoke an invite link.
*
* If `link` is a primary invite link, a new invite link will be
* generated automatically by Telegram
*
* @param chatId Chat ID
* @param link Invite link to revoke
* @returns If `link` is a primary invite, newly generated invite link, otherwise the revoked link
* @internal
*/
export async function revokeInviteLink(
this: TelegramClient,
chatId: InputPeerLike,
link: string
): Promise<ChatInviteLink> {
const res = await this.call({
_: 'messages.editExportedChatInvite',
peer: await this.resolvePeer(chatId),
link,
revoked: true,
})
const peers = PeersIndex.from(res)
const invite =
res._ === 'messages.exportedChatInviteReplaced'
? res.newInvite
: res.invite
return new ChatInviteLink(this, invite, peers)
}