I
I
Ivan2022-01-05 14:07:59
JavaScript
Ivan, 2022-01-05 14:07:59

How to catch 403 error in Telegram API?

Hello! Please tell me how to solve the problem.

We have a function.
bot.sendMessage(message.chat.id, text, params)
Sometimes it returns an error, saying that the user has blocked the bot.
TelegramError: ETELEGRAM: 403 Forbidden: bot was blocked by the user

We need to catch this error. Tried to do so, did not work.

try{
bot.sendMessage(message.chat.id, text, params)
} catch {
console.log('Ошибка 00')
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question