mtcute/packages/client/src/methods/contacts/get-contacts.ts
2021-04-25 17:10:37 +03:00

20 lines
556 B
TypeScript

import { TelegramClient } from '../../client'
import { User } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion'
import { tl } from '@mtcute/tl'
/**
* Get list of contacts from your Telegram contacts list.
* @internal
*/
export async function getContacts(
this: TelegramClient
): Promise<User[]> {
const res = await this.call({
_: 'contacts.getContacts',
hash: 0
})
assertTypeIs('getContacts', res, 'contacts.contacts')
return res.users.map((user) => new User(this, user as tl.RawUser))
}