diff --git a/packages/node/index.ts b/packages/node/index.ts index 6b42af05..e63d3bf8 100644 --- a/packages/node/index.ts +++ b/packages/node/index.ts @@ -89,10 +89,7 @@ export class NodeTelegramClient extends TelegramClient { return new Promise((res) => this._rl!.question(text, res)) } - run( - params: Parameters[0], - then?: (user: User) => void | Promise - ): void { + start(params: Parameters[0] = {}): Promise { if (!params.botToken) { if (!params.phone) params.phone = () => this.input('Phone > ') if (!params.code) params.code = () => this.input('Code > ') @@ -100,13 +97,13 @@ export class NodeTelegramClient extends TelegramClient { params.password = () => this.input('2FA password > ') } - super.run(params, (user) => { + return super.start(params).then((user) => { if (this._rl) { this._rl.close() delete this._rl } - return then?.(user) + return user }) }