Jump to content
McKay Development

Recommended Posts

Posted

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!
 
 
Posted

Did you ever log on with the client?

In the main file, yes.

client.setOption("promptSteamGuardCode", false);

const logOnOptions = {
	accountName: config.username,
	password: config.password,
	rememberPassword: true,
	twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)
};
client.logOn(logOnOptions);
Posted

If the code you posted in your original post is that entire file, then that specific client is not logged on. You instead created a new one.

Excellent, thank you for the help!

 

Im now just supplying the "client" information in the request.

 

Thanks again!

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...