In my code with tg bot and database there was a problem with the exchange function. The bot was exchanging some user coins for others. Here is the user model:
class User: lucky: Mapped[int] = mapped_column(Integer) chip: Mapped[int] = mapped_column(Integer) cash: Mapped[int] = mapped_column(Integer)And this is my function in which I have to check that the coin exchange that comes in the parameters as a string is equal to some of the database and perform the exchange action. Here is the code:
async def trade(callback: CallbackQuery, state: FSMContext): data = await state.get_data() # here is my data including the number of coins if data['send_coin'] == 'lucky': if data['get_coin'] == 'cash' user = await get_user() user.lucky -= 10 # update user model user.cash += 1 # and so on with each coin, that is 6 more ifsI couldn't google the question, so I asked here.