mtcute/packages/client/src/methods/contacts/get-contacts.ts

20 lines
538 B
TypeScript
Raw Normal View History

import Long from 'long'
2021-04-25 17:10:37 +03:00
import { TelegramClient } from '../../client'
import { User } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion'
/**
* Get list of contacts from your Telegram contacts list.
* @internal
*/
export async function getContacts(this: TelegramClient): Promise<User[]> {
2021-04-25 17:10:37 +03:00
const res = await this.call({
_: 'contacts.getContacts',
hash: Long.ZERO,
2021-04-25 17:10:37 +03:00
})
assertTypeIs('getContacts', res, 'contacts.contacts')
return res.users.map((user) => new User(this, user))
2021-04-25 17:10:37 +03:00
}