node-telegram-api icon indicating copy to clipboard operation
node-telegram-api copied to clipboard

ERR_UNHANDLED_ERROR error

Open arsamigullin opened this issue 7 years ago • 0 comments

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object]) at Bot.emit (events.js:171:17) at Bot.EventEmitter.emit (domain.js:442:20) at /root/nodeapp/node_modules/telegram-api/build/functions/poll.js:19:9 at run (/root/nodeapp/node_modules/core-js/modules/es6.promise.js:75:22) at /root/nodeapp/node_modules/core-js/modules/es6.promise.js:92:30 at flush (/root/nodeapp/node_modules/core-js/modules/_microtask.js:18:9) at process._tickCallback (internal/process/next_tick.js:61:11)

What I have: telegram-api : v4.1.0 OS : Ubuntu 16.04.3 x64 Node js : v10.2.1 npm : v6.4.1

The code I use:

var bot = new Bot({
  token: config.botkey
});

bot.on('command-notfound', message => {
  if (message.chat.id > 0) {
    bot.send(new Message().text('Command not found').to(message.chat.id));
  }
});

async function notifyUser(chatId, msg, options) {
  try{
    await bot.send(new Message().text(msg).to(chatId));
    logger.info('test was sent');
  } catch(ex){
    logger.error('error wile sending : ' + JSON.stringify(ex))
  }
}

bot.start();

arsamigullin avatar Oct 03 '18 09:10 arsamigullin