DoctorMcKay/node-steam-tradeoffer-manager

Error: Not Logged In (On second trade offer accept)

Andrew3019 opened this issue · 2 comments

Hello,

When I try to accept an offer the first time, it works, but the second time, it always throws "Error: Not Logged In".

Code (runs every 15 seconds):

function acceptOffers(resolve) {

    const db = new sqlite3.Database(db_filepath);

    const selectQuery = 'SELECT * FROM steam_tradeoffers LIMIT 1';
    db.get(selectQuery, (err, row) => {
        if (err) {
            console.error('Error selecting entry:', err);
            resolve(err)
        }
        console.log(row)

        if (row) {

            // Delete the picked entry from the table
            const deleteQuery = `DELETE FROM steam_tradeoffers WHERE tradeofferid = ${row.tradeofferid}`;
            db.run(deleteQuery, (err) => {
                if (err) {
                    console.error('Error deleting entry:', err);
                }
            });
            db.close(); // Close the database connection

            // Perform your desired operations on the entry
            const info_str = row.text + " - " + row.user;

            manager.getOffer(row.tradeofferid, (err, offer) => {
                if (err) console.log(err);
                offer.accept(true, (err, status) => {
                    if (err && status != "accepted") console.log(err);
                    else if (status == "accepted") {
                        console.log("Accepted offer - " + info_str);
                        resolve(true)
                    }
                    else {
                        console.log("Accepting error - " + info_str);
                    }
                })
            })
        }
    })
}

Output:

{
  tradeofferid: '6235459445',
  user: '未央',
  text: 'The seller has sent a offer'
}
Error: Not Logged In
    at SteamCommunity.<anonymous> (C:\Users\Andrew\node_modules\steam-trad
eoffer-manager\lib\classes\TradeOffer.js:483:25)
    at Request._callback (C:\Users\Andrew\node_modules\steamcommunity\comp
onents\http.js:67:15)
    at Request.self.callback (C:\Users\Andrew\node_modules\request\request
.js:185:22)
    at Request.emit (node:events:513:28)
    at Request.<anonymous> (C:\Users\Andrew\node_modules\request\request.j
s:1154:10)
    at Request.emit (node:events:513:28)
    at Gunzip.<anonymous> (C:\Users\Andrew\node_modules\request\request.js
:1076:12)
    at Object.onceWrapper (node:events:627:28)
    at Gunzip.emit (node:events:513:28)
    at endReadableNT (node:internal/streams/readable:1358:12)


Also doesnt work on subsequent runs if I run the program once, accept a tradeoffer, terminate the program, and run it again.