From e3ded988c27e5b56ea691a37d89741349eea2bb2 Mon Sep 17 00:00:00 2001 From: Kravets <57632712+kravetsone@users.noreply.github.com> Date: Sun, 1 Sep 2024 16:22:54 +0300 Subject: [PATCH] chore: improve error for 404 getMe --- src/bot.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index 17b0f88..e0e4a3a 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1157,7 +1157,17 @@ export class Bot< this.lazyloadPlugins.map(async (plugin) => this.extend(await plugin)), ); - this.info = await this.api.getMe(); + const info = await this.api.getMe({ + suppress: true, + }); + + if (info instanceof TelegramError) { + if (info.code === 404) + info.message = "The bot token is incorrect. Check it in BotFather."; + throw info; + } + + this.info = info; } /**