const {Api,TelegramClient} =require('telegram');const {StringSession} =require('telegram/sessions');constsession=newStringSession('');constclient=newTelegramClient(session, apiId, apiHash, {});(asyncfunctionrun() {constresult=awaitclient.invoke(newApi.account.updateUsername({ username:'random string here', }));console.log(result); // prints the result})();
import {Api, TelegramClient} from'telegram';import {StringSession} from'telegram/sessions';constsession=newStringSession('');constclient=newTelegramClient(session, apiId, apiHash, {});(asyncfunctionrun() { const result: Api.Returns updated information on the user in a User type object. = await client.invoke(new Api.account.updateUsername({
username:'random string here', }));console.log(result); // prints the result})();