message.entities only contains metadata right? Not the actual user data ?
@dp.message(Command("buy"))
@UsOper.public
async def buy_item(message: Message, bot: Bot): # Add bot parameter
try:
text_words = message.text.split()
if len(text_words) == 3:
username = text_words[1].replace("@", "")
chat_member = await bot.get_chat_member(message.chat.id, username)
user_id = chat_member.user.id
item_title = text_words[2]
elif len(text_words) == 2:
item_title = text_words[1]
user_id = message.from_user.id
await AssortOper.buy_item(item_title, user_id, message.chat.id)
await message.reply(f"Item {item_title} purchased!")
except Exception as ex:
print(ex, "__buy_item")