I’m having trouble with my Discord bot code after upgrading to python-telegram-bot v20. When I try to run my bot, I get a TypeError saying that the Updater constructor is missing a required argument called ‘update_queue’.
Here’s the error message I’m getting:
Traceback (most recent call last):
File "/home/user/projects/chatbot/bot_main.py", line 98, in <module>
initialize_bot()
File "/home/user/projects/chatbot/bot_main.py", line 89, in initialize_bot
bot_updater = Updater("BOT-TOKEN-HERE")
TypeError: __init__() missing 1 required positional argument: 'update_queue'
Yes, this issue arises when upgrading from older versions of the python-telegram-bot. The Updater class was removed in v20, and you need to use the Application class. Replace your Updater instantiation with Application.builder().token(“YOUR_TOKEN”).build(). Change any references from dispatcher to application, and call add_handler directly on the application object. Instead of start_polling() and idle(), use application.run_polling(). Here is the modified code:
Had the exact same problem migrating from v13 to v20. Total pain because it’s not just swapping Updater for Application - you’ve got to change how handlers work too. In v20, context becomes the second parameter, so your functions need to go from def welcome_user(update, context) to async def welcome_user(update: Update, context: ContextTypes.DEFAULT_TYPE). Make sure you import Update and ContextTypes from telegram and telegram.ext. Also heads up - lots of methods that used to be sync now need await, so you’ll be adding await before stuff like context.bot.send_message(). The official migration guide on their GitHub breaks down all the breaking changes pretty well.
yeah, they completely removed the updater class in v20 - that’s why you’re getting the error. you’ll need to rewrite your handlers as async functions since that’s required now. also, make sure to import Application from telegram.ext instead of updater.