-1

I have no idea how to fix it

I try this:

@Router.message(F.text == "/start")
async def send_welcome(message: types.Message, state: FSMContext):
 await state.set_state(UserState.awaiting_function) # встановлюємо стан
 await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")

And this:

@dp.message(lambda message: message.text.lower() == '/start', state = FSMContext)
async def send_welcome(message: types.Message):
 await state.set_state(UserState.awaiting_function)
 """ Greets the user and introduces the bot """
 await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")

Thats an error:

Traceback (most recent call last):
 File "C:\Users\USER\PycharmProjects\PythonProject\bot_main\main.py", line 26, in <module>
 @Router.message(FSMContext.text == "/start")
 ^^^^^^^^^^^^^^
AttributeError: type object 'Router' has no attribute 'message'

Someone can help me?`

asked Sep 22, 2025 at 20:25

1 Answer 1

2

I suppose the router is imported from aiogram and as per the docs that is not the right way to use it as you should create an instance of the Router
https://docs.aiogram.dev/en/dev-3.x/dispatcher/router.html

your code would look like this

from aiogram import Router
# your other imports
my_router = Router(name=__name__) # --> you have to create an instance of the router not use it directly
@my_router.message() # pass your parameters here F.text == "/start"
async def send_welcome(message: types.Message, state: FSMContext):
 await state.set_state(UserState.awaiting_function) # встановлюємо стан
 await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
answered Sep 22, 2025 at 21:22
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.