Jump to content
McKay Development

lll

Member
  • Content Count

    2
  • Joined

  • Last visited

  1. This logic will be written in the constructor. Something like this : constructor(accountName) { this.setCookies = util.promisify(this.manager.setCookies).bind(this.manager); this.user.on('error', this.logOut); this.user.on('loginKey', loginKey => db.findOne('bot', { accountName }, { loginKey })); }
  2. I have a Bot class and an async method for logIn, are there any better way for writing this method? completeLogin(botDetails, useLoginKey) { this.user.logOn(this.details(botDetails, useLoginKey)); return new Promise((done, reject) => { const cxt = this; async function success(_, cookies) { try { await cxt.setCookies(cookies); cxt.user.off('error', failed); done(); } catch(err) { reject(err); } } function failed(err) { cxt.user.off('webSession', success); reject(err); } cxt.user.once('webSession', success); cxt.user.once('error', failed); }); }
×
×
  • Create New...