mtcute/packages/client/src/methods/users/get-me.ts

26 lines
606 B
TypeScript
Raw Normal View History

2021-04-08 12:19:38 +03:00
import { TelegramClient } from '../../client'
import { User } from '../../types'
import { assertTypeIs } from '../../utils/type-assertion'
/**
* Get currently authorized user's full information
*
* @internal
*/
export function getMe(this: TelegramClient): Promise<User> {
return this.call({
_: 'users.getUsers',
id: [
{
_: 'inputUserSelf',
},
],
}).then(([user]) => {
assertTypeIs('getMe (@ users.getUsers)', user, 'user')
2021-04-08 12:19:38 +03:00
this._selfUsername = user.username ?? null
return new User(this, user)
2021-04-08 12:19:38 +03:00
})
}