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

20 lines
542 B
TypeScript
Raw Normal View History

2023-10-05 01:47:14 +03:00
import { Long } from '@mtcute/core'
2023-09-22 15:32:28 +03:00
import { assertTypeIs } from '@mtcute/core/utils'
2021-04-25 17:10:37 +03:00
import { TelegramClient } from '../../client'
import { User } from '../../types'
/**
* 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
}