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

18 lines
517 B
TypeScript
Raw Normal View History

import { BaseTelegramClient, Long } from '@mtcute/core'
import { assertTypeIs } from '@mtcute/core/utils.js'
2023-09-22 15:32:28 +03:00
import { User } from '../../types/index.js'
2021-04-25 17:10:37 +03:00
/**
* Get list of contacts from your Telegram contacts list.
*/
export async function getContacts(client: BaseTelegramClient): Promise<User[]> {
const res = await client.call({
2021-04-25 17:10:37 +03:00
_: '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(user))
2021-04-25 17:10:37 +03:00
}