Jump to content
McKay Development
Sign in to follow this  
metrize

Rich presence

Recommended Posts

Hi

 

I was looking at grabbing the rich presence for a user, I've looked at this 

and I'm trying to do something similar, and I've got the code below based off of that:

const SteamUser = require('steam-user');
const client = new SteamUser();
 
client.logOn();
 
let sID = 76561198204940988
let rPresence = client.users[sID].rich_presence
 
console.log(rPresence)

 

 

I'm keep getting the error TypeError: Cannot read property 'rich_presence' of undefined

I'm unsure of what to do, do I need to log on with an actual account instead of anonymous account?

 

Thanks

 

 

Edited by metrize

Share this post


Link to post
Share on other sites

Thanks, I've tried this:

I'm still getting undefined for both the getPersonas and richPresence unless something else is wrong

 

Thanks

const SteamUser = require('steam-user');
const client = new SteamUser();
 
client.logOn()
client.setPersona(SteamUser.EPersonaState.Online);
 
client.on('loggedOn', (details=> {
    console.log("Logged onto Steam as " + client.steamID.getSteam3RenderedID());
    
let sID = 76561198204940988
const x = client.getPersonas[sID]
console.log(x)
let rPresence = client.users[sID].richPresence
console.log(rPresence)
 
})
Edited by metrize

Share this post


Link to post
Share on other sites

Thanks for all the help, I've made changes and the request is now just timing out according to the promise. I'm sure I must have messed something else up but I'm not quite sure where:

 

const SteamUser = require('steam-user');
const client = new SteamUser();
 
client.logOn()
client.setPersona(SteamUser.EPersonaState.Online);
 
client.on('loggedOn', (details=> {
    console.log("Logged onto Steam as " + client.steamID.getSteam3RenderedID());
    
let sID = 76561198204940988
const x = client.getPersonas([sID]).then(console.log(client.users[sID]))
 
})
Edited by metrize

Share this post


Link to post
Share on other sites

This seems to work, though I'm getting an empty array: 

client.on('loggedOn', (details) => {
    console.log("Logged onto Steam as " + client.steamID.getSteam3RenderedID());
    client.setPersona(SteamUser.EPersonaState.Online);
    
    let steamID = 0;

    client.getPersonas([steamID]).then(function ({ personas }) {
        let richPresence = personas[steamID].rich_presence;

        console.log((richPresence));
    });

    /*
        Above is the same as
        client.getPersonas([steamID]).then(function (obj) {
            let personas = obj.personas;
            // code
        });
    */
});

 

Share this post


Link to post
Share on other sites
17 hours ago, vrtgn said:

This seems to work, though I'm getting an empty array: 

client.on('loggedOn', (details) => {
    console.log("Logged onto Steam as " + client.steamID.getSteam3RenderedID());
    client.setPersona(SteamUser.EPersonaState.Online);
    
    let steamID = 0;

    client.getPersonas([steamID]).then(function ({ personas }) {
        let richPresence = personas[steamID].rich_presence;

        console.log((richPresence));
    });

    /*
        Above is the same as
        client.getPersonas([steamID]).then(function (obj) {
            let personas = obj.personas;
            // code
        });
    */
});

 

i'm getting request timed out for this one too

Share this post


Link to post
Share on other sites
3 hours ago, metrize said:

i'm getting request timed out for this one too

What do you mean it is timing out? What error does it throw, if any?

Share this post


Link to post
Share on other sites
On 6/5/2020 at 1:25 PM, vrtgn said:

What do you mean it is timing out? What error does it throw, if any?

Logged onto Steam as [a:1:468273475]
testRP.js:9
 
 
(node:8160) UnhandledPromiseRejectionWarning: Error: Request timed out at Timeout._onTimeout (c:\Users\Jay\Desktop\test\node_modules\@doctormckay\stdlib\components\promises.js:17:12) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7)
warning.js:32
 
 
(node:8160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
warning.js:32
 
 
(node:8160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Share this post


Link to post
Share on other sites

Timing out because the SteamID is invalid (in this case 0?)

getPersonas from what I understand is supposed to work correctly for friends, but I've found its behaviour to be inconsistent.

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...