Ошибка A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found

Вот сам код:

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    cursor.execute('SELECT userid, wine_quantity FROM accounts ORDER BY wine_quantity DESC LIMIT 15')
    accounts = cursor.fetchall()
    try:

        if call.data == '1':
            cursor.execute('SELECT userid, wine_quantity FROM accounts ORDER BY wine_quantity DESC LIMIT 15')
            accounts = cursor.fetchall()
            database.commit()
            try: 
                top_users = "\n".join(
                    f"{accounts.index(user)+1}. <a href=\"t.me/{bot.get_chat_member(user[0], user[0]).user.username}\">{bot.get_chat_member(user[0], user[0]).user.first_name}</a> Рейтинг: {user[1]}"
                    for user in accounts
                )
                
                bot.edit_message_text(
                    chat_id=call.message.chat.id,
                    message_id=call.message.message_id,
                    text="ТОП ПО ВЫПИТОМУ ВИНУ\n\n" + top_users,
                    parse_mode="HTML",
                    disable_web_page_preview=True
                )
            except telebot.apihelper.ApiTelegramException as e:
                print(f'Не удалось отправить сообщение пользователю {call.from_user.id}: {e}')
                # Дополнительная обработка ошибки (например, логирование или уведомление)
            except Exception as e:
                print(f'Произошла непредвиденная ошибка: {e}')
        elif call.data == '2':
            cursor.execute('SELECT userid, whiskey_quantity FROM accounts ORDER BY whiskey_quantity DESC LIMIT 15')
            accounts = cursor.fetchall()
            database.commit()

            try: 
                # Проверяем, есть ли аккаунты и последовательно формируем строку
                if accounts:
                    top_users = "\n".join(
                        f"{accounts.index(user)+1}. <a href=\"t.me/{bot.get_chat_member(user[0], user[0]).user.username}\">{bot.get_chat_member(user[0], user[0]).user.first_name}</a> Рейтинг: {user[1]}"
                        for user in accounts
                    )
                    
                    bot.edit_message_text(
                        chat_id=call.message.chat.id,
                        message_id=call.message.message_id,
                        text="ТОП ПО ВЫПИТОМУ ВИСКИ\n\n" + top_users,
                        parse_mode="HTML",
                        disable_web_page_preview=True
                    )
                else:
                    bot.edit_message_text(
                        chat_id=call.message.chat.id,
                        message_id=call.message.message_id,
                        text="Нет данных для отображения.",
                        parse_mode="HTML",
                        disable_web_page_preview=True
                    )

            except telebot.apihelper.ApiTelegramException as e:
                print(f'Не удалось отправить сообщение пользователю {call.from_user.id}: {e}')
            except Exception as e:
                print(f'Произошла непредвиденная ошибка: {e}')

Ответы (0 шт):