Closed arewageek closed 2 months ago
The error message explains the problem very well. Here is what your code does:
bot.start
/bot
bot.command("start")
This means that if you handle 1000 requests, your bot will now have 1000 identical start commands handlers registered. That's not what you meant to do, and grammY detects this and throws an error.
Note that your code:
You should probably take a second (first?) look at how to use webhooks. https://grammy.dev/guide/deployment-types#how-to-use-webhooks
Thank you so much for that. Will read through the guide you sent. But I have one question please. does this mean the bot start command is supposed to be written outside the route?
does this mean the bot start command is supposed to be written outside the route?
Yep, exactly! First set up your bot with all handlers, then turn it into a callback function using webhookCallback
, then set up your routes which call this function.
Thank you so much. I read about the concurrency with grammY runner docs and I got to understand it better. I migrated to the long polling instead. It's working perfectly now. Thank you so much 😁
I would get back to learning about the webhook. As soon as I perfectly understand it I will get my hands working on it.
Thank you so much for your support. You're a real MVP
Whenever a message is sent to the bot, it always throws an error in the console suggesting I'm registering more listeners in the bot.
Here's the error message it returns:
Above is the complete error on my console
Here's the implementation I did in my code
I've tried checking for help online but failed to get any related to my problem. I will really appreciate it if I get a response real quick.