'How to wait for messages from user pyrogram

example of my code, but when the bot switches to another command, this remains Is there an example of how this can be done?

async def test(client, message):
    user_id = message.chat.id
    await bot.send_message(user_id, "write code:")
    @bot.on_message(filters.private & filters.user(user_id))
    async def get_code(client, message):
        code = message.text```


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source