From d8bf9377a6718a782657c91347618588fbd7363a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rog=C3=A9rio=20Munhoz?= Date: Mon, 3 Jul 2023 13:08:26 -0300 Subject: [PATCH] bugfix: catch error when answering query --- src/bot.ts | 2 ++ src/handlers/registered.ts | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index 4e1b1ef..b3fefa3 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -49,8 +49,10 @@ export async function getBot(config: AppConfig, development = false) { if (development) { bot.use(async (ctx, next) => { + console.time("update"); console.log(ctx.update); await next(); + console.timeEnd("update"); }); } diff --git a/src/handlers/registered.ts b/src/handlers/registered.ts index d445b16..4c4fa56 100644 --- a/src/handlers/registered.ts +++ b/src/handlers/registered.ts @@ -46,6 +46,10 @@ export function install(bot: Bot) { const formattedAmount = BRL(finalValue); + await new Promise((resolve) => { + setTimeout(resolve, 15000); + }); + return ctx.answerInlineQuery([ { id: query, @@ -82,6 +86,7 @@ export function install(bot: Bot) { finalValue.toFixed(2), ), }, - ], { cache_time: 0 }); + ], { cache_time: 0 }) + .catch(console.error); }); }