Jump to content
McKay Development

Trying to integrate node-steam-user with a discord bot


azz_man

Recommended Posts

So I want to create a very simple discord bot. I already have it running except I cannot figure out how to integrate this library properly. I want the bot to simply retrieve the amount of players on a certain steam game and then return the amount of players. Here's my code so far:

 

const SteamUser = require('./node-steam-user-master/index.js');
var user = new SteamUser();

user.login({
"accountName": "",
"password": ""
});

user.on('loggedOn', function(details){
console.log(user.steamID);
})

 

I will also note I have been getting an error when I try to run this code (I do have the accountName and password fields filled in on my actual program) This is the error I get: 

----------------------------------------------------------------------------------------------------------------------

internal/modules/cjs/loader.js:638

    throw err;
    ^
 
Error: Cannot find module '@doctormckay/stats-reporter'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (D:\Discord_Code\bot\node-steam-user-master\index.js:1:1)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
----------------------------------------------------------------------------------------------------------------------
 
So that's my first problem, but the other is how do I use the getPlayerCount Method? I'm assuming I need to use a different constructor because the SteamUser doesn't seem to have that method available.
 
Any help would be appreciated, thanks.
 
Link to comment
Share on other sites

You're welcome to use the module by downloading it from Github, but that's ill-advised. You should be using npm install steam-user on the command line to download the library. But if you really really want to download from Github, you'll need to run npm install inside the module directory to download dependencies.

 

Once you're logged on, you should be able to use user.getPlayerCount(...)

Link to comment
Share on other sites

Ok that helped and made a lot more sense. So I am now able to use the command however it is not returning the player count. I'm positive it's because I'm not using the method correctly as I'm not sure what to put for the second parameter. Right now I have this: 

const SteamUser = require('steam-user');
var user = new SteamUser();

user.logOn();
console.log(user.getPlayerCount(504370,30));

and when I print the player count I get this as a result: 

 

Promise { <pending> }

 

I also tried to do:

var count = Promise.resolve(user.getPlayerCount(504370,[]))
console.log(count);

 

however this still just prints:

Promise { <pending> }

 

Any idea what I'm doing wrong, I'm sure it's a lot as I'm very new to this.

Link to comment
Share on other sites

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...