diff --git a/src/functions/poll.js b/src/functions/poll.js index eb71b03..27b640f 100644 --- a/src/functions/poll.js +++ b/src/functions/poll.js @@ -1,13 +1,17 @@ export default function poll(bot) { - return bot.api.getUpdates(bot.update).then(response => { - if (!response.result.length) { - return poll(bot); - } - bot.emit('update', response.result); + return bot.api.getUpdates(bot.update) + .then(response => { + if (!response.result.length) { + return poll(bot); + } + bot.emit('update', response.result); - if (bot._stop) { - return null; - } - return poll(bot); - }); + if (bot._stop) { + return null; + } + return poll(bot); + }) + .catch(() => { + return poll(bot); + }); }