alik0211 / mtproto-core

Telegram API JS (MTProto) client library for Node.js and browser
https://mtproto-core.js.org
GNU General Public License v3.0
630 stars 113 forks source link

Cannot read property 'call' of undefined #208

Open Marco-Gtto opened 3 years ago

Marco-Gtto commented 3 years ago

I'm trying to get an user:

user_id = parseInt(warnList[0]["staffer"]) 
console.log("ID:", user_id)

staffer = await api.call('users.getFullUser', {id: user_id});
console.log(staffer)

Below what is printed by console.log("ID:", user_id): ID: 935648014

I'm getting this error: users.getFullUser error: TypeError: Cannot read property 'call' of undefined

Maybe this issue is caused due to a bad parameter. However i have no idea about the right parameter to use. Help would be appreciated

exilibriss commented 2 years ago

Param id's type need to be InputUser, not int https://core.telegram.org/method/users.getFullUser https://core.telegram.org/type/InputUser https://core.telegram.org/constructor/inputUser

e.g. inputUserSelf

const user_info = await api.call('users.getFullUser', {
    id: {
        _: 'inputUserSelf'
    }
})
console.log(user_info);

inputUser

const user_info = await api.call('users.getFullUser', {
    id: {
        _: 'inputUser',
        user_id: 94032407,
        access_hash: 'access_hash value from the User constructor',
    }
})
console.log(user_info);