Jump to content
McKay Development

Space Engineer

Member
  • Posts

    3
  • Joined

  • Last visited

Posts posted by Space Engineer

  1. Hello mates!

    This might be a weird question, but I'm having trouble getting "client.getPersonas" to function in a module.export.
     

    Here is my file my problem is located in:
    (Problem is in the exports.GetSteamName)

    var exports = module.exports = {};
    
    var SteamUser = require('steam-user');
    var client = new SteamUser();
    
    const SteamRepAPI = require('steamrep');
    
    exports.CheckRep = function (SteamId64) {
        return new Promise(resolve => {
            SteamRepAPI.isScammer(SteamId64, function (err, result) {
                if (err) {
                    console.log("Error Checking SteamREP for " + SteamId64);
                    resolve(true); // true == Not a scammer
                } else {
                    if (result) {
                        console.log("eww thats gross")
                        resolve(false);
                    } else {
                        console.log("Got Not-Scammer!")
                        resolve(true); // true == Not a scammer
                    }
                }
            });
        })
    }
    
    exports.GetSteamName = function (SteamID) {
        return new Promise(resolve => {
            client.getPersonas([SteamID], function (personas) {
                persona = personas[SteamID.getSteamID64()];
                name = persona ? persona.player_name : ("[" + SteamID.getSteamID64() + "]");
                resolve(name)
            })
        })
    }
    

    What happens is once the program gets to"client.getPersonas([steamID], function (personas) {" , it seems to run over everything inside of the function(personas). Including the "resolve"

    If I were to change exports.GetSteamName to:

    exports.GetSteamName = function (SteamID) {
        return new Promise(resolve => {
            client.getPersonas([SteamID], function (personas) {
                persona = personas[SteamID.getSteamID64()];
                name = persona ? persona.player_name : ("[" + SteamID.getSteamID64() + "]");
                resolve(name)
            })
            console.log("Fired?")
        })
    }
    
    I will get back "Fired?" in console.
     
     
    The problem is present in another file I am using for Chat messages.
    The problem is not present in "CheckRep".
     
    This could just be me not understanding how module.exports works exactly as this is still a somewhat new concept for me.
    CheckRep, however, works as expected and that's what I'm getting caught up on.
     
    I think it could be that "SteamUser" and "client" are being called more than expected (I'm declaring them in multiple files).
    SteamRepAPI is only declared in this file.
     
    I have resorted to moving the function into the main file, which works as expected. I would greatly prefer it to function in this file.
     
     
    Taken from package.json:
    "steam-user": "^3.28.2",
     
     
    Any help is greatly appreciated, Thanks!
     
     
×
×
  • Create New...