metrize Posted June 3, 2020 Report Posted June 3, 2020 (edited) 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 June 3, 2020 by metrize Quote
Dr. McKay Posted June 4, 2020 Report Posted June 4, 2020 You need to wait for the loggedOn event, and you also need to call getPersonas to actually get user persona data. metrize 1 Quote
metrize Posted June 4, 2020 Author Report Posted June 4, 2020 (edited) 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 June 4, 2020 by metrize Quote
Dr. McKay Posted June 4, 2020 Report Posted June 4, 2020 getPersonas is a method, not a property. metrize 1 Quote
metrize Posted June 4, 2020 Author Report Posted June 4, 2020 (edited) 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 June 4, 2020 by metrize Quote
vrtgn Posted June 4, 2020 Report Posted June 4, 2020 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 }); */ }); Quote
metrize Posted June 5, 2020 Author Report Posted June 5, 2020 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 Quote
vrtgn Posted June 5, 2020 Report Posted June 5, 2020 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? Quote
metrize Posted June 8, 2020 Author Report Posted June 8, 2020 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. Quote
jfx. Posted July 31, 2020 Report Posted July 31, 2020 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. Quote
Dr. McKay Posted July 31, 2020 Report Posted July 31, 2020 Quote Logged onto Steam as [a:1:468273475] The "a" instead of "U" means you logged on anonymously. Most things, including requesting persona data, don't work when logged on anonymously. Quote
Recommended Posts
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.