ec736f8590
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
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { TelegramClient } from '../../client'
|
|
import { ChatInviteLink, InputPeerLike, PeersIndex } from '../../types'
|
|
import { normalizeDate } from '../../utils/misc-utils'
|
|
|
|
/**
|
|
* Edit an invite link. You can only edit non-primary
|
|
* invite links.
|
|
*
|
|
* Only pass the fields that you want to modify.
|
|
*
|
|
* @param chatId Chat ID
|
|
* @param link Invite link to edit
|
|
* @param params
|
|
* @returns Modified invite link
|
|
* @internal
|
|
*/
|
|
export async function editInviteLink(
|
|
this: TelegramClient,
|
|
chatId: InputPeerLike,
|
|
link: string,
|
|
params: {
|
|
/**
|
|
* Date when this link will expire.
|
|
* If `number` is passed, UNIX time in ms is expected.
|
|
*/
|
|
expires?: number | Date
|
|
|
|
/**
|
|
* Maximum number of users that can be members of this chat
|
|
* at the same time after joining using this link.
|
|
*
|
|
* Integer in range `[1, 99999]` or `Infinity`,
|
|
*/
|
|
usageLimit?: number
|
|
}
|
|
): Promise<ChatInviteLink> {
|
|
const res = await this.call({
|
|
_: 'messages.editExportedChatInvite',
|
|
peer: await this.resolvePeer(chatId),
|
|
link,
|
|
expireDate: normalizeDate(params.expires),
|
|
usageLimit: params.usageLimit,
|
|
})
|
|
|
|
const peers = PeersIndex.from(res)
|
|
|
|
return new ChatInviteLink(this, res.invite, peers)
|
|
}
|