DoctorMcKay / node-globaloffensive

A Node.js module to connect to and interact with the CS2 game coordinator. Mostly used to get item data.
https://www.npmjs.com/package/globaloffensive
MIT License
262 stars 61 forks source link

how to get recent games of the user? (requestRecentGames(steamid)) #69

Closed ccastrom closed 2 years ago

ccastrom commented 2 years ago

Greetings to all. I'm a newbie using this repository and javaScript. I was investigate and manipulating a lot of projects to obtain some knowledge to create basic things. My question is this: How can i get recent games of the user? I don't understand how the get a response from the event 'matchList'. I did a lot of things but no one make sense and end in more confusion. If someone can guide me I will be grateful.

consoleOutput


const steam_user = require("steam-user");
const global = require("globaloffensive");
const chalk = require("chalk")
var client = new steam_user();
var csgo = new global(client);
let login = 'account';
let password = 'pass';
client.logOn({
    "accountName": login,
    "password": password
});

client.on('loggedOn', function() {
    console.log("Logged into Steam");
    client.setPersona(steam_user.EPersonaState.Invisible);
    client.gamesPlayed(730);
});

client.on('error', function(a) {
    console.log(a);
});
    csgo.on('debug', console.log);
    csgo.on("connectedToGC", function() {
        if ( csgo.haveGCSession ) {
            csgo.requestPlayersProfile(steamID, function(data) {
              console.log(chalk.green(JSON.stringify(data, null, 3))); //working!
              csgo.requestRecentGames(steamID)
              csgo.on('matchList',(match,data) => {
                //I don't understand what to do here.
            });
              process.exit();
            })

         }

    })