For the sake of studying the capabilities of the Telegram API, the question arose, how to get the @username of a bot in a telegram using aiogram?
I tried username = bot.get_me().username
but gives the following error:
AttributeError: 'coroutine' object has no attribute 'username'
How can this be fixed?
2
Answers
You can get the username of the bot by calling
get_me
on theBot
object.The returned objects hold the
username
you are looking for.Example code:
Its because u tryna get attribute of coro, not coro returned object