Skip to content

Commit dba2761

Browse files
author
AffanTheBest
committed
Add try catch
1 parent b8f641f commit dba2761

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

bot.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ bot.command('track', async ctx => {
4444
const sentMsg = await ctx.reply(`Tracking ${merchant} product...`, { reply_to_message_id: ctx.message.message_id });
4545
const details = await getProductDetails(productUrl, merchant);
4646
if (details.ok) {
47-
const tracking_id = getRandomId();
48-
await manageProducts({ tracking_id, userId: ctx.from.id, merchant, title: details.title, link: details.link, initPrice: details.price, price: details.price }, 'update');
49-
await ctx.api.editMessageText(ctx.chat.id, sentMsg.message_id,
50-
`<a href="${details.image}"> </a>\nTracking <b>${details.title}</b>\n\nCurrent Price: <b>${details.price}</b>\nLink: <a href="${details.link}">${merchant}</a>\n\nTo stop tracking send /stop_${tracking_id}`,
51-
{ parse_mode: "HTML", reply_markup }
52-
);
47+
try{
48+
const tracking_id = getRandomId();
49+
await manageProducts({ tracking_id, userId: ctx.from.id, merchant, title: details.title, link: details.link, initPrice: details.price, price: details.price }, 'update');
50+
await ctx.api.editMessageText(ctx.chat.id, sentMsg.message_id,
51+
`<a href="${details.image}"> </a>\nTracking <b>${details.title}</b>\n\nCurrent Price: <b>${details.price}</b>\nLink: <a href="${details.link}">${merchant}</a>\n\nTo stop tracking send /stop_${tracking_id}`,
52+
{ parse_mode: "HTML", reply_markup }
53+
);
54+
}catch(e){}
5355
} else {
5456
await ctx.api.editMessageText(ctx.chat.id, sentMsg.message_id, `Sorry, I couldn't track this product. Make sure you've sent correct product link.`, { parse_mode: "Markdown", reply_markup });
5557
}

0 commit comments

Comments
 (0)