justarandomdeveloper Posted February 15, 2018 Report Posted February 15, 2018 (edited) Hey, so I have this function, as follows: checkFriendsAndMessagesWhileOffline() {this.client.on('friendsList', () => {let friendcount = 0;Object.keys(this.client.myFriends).forEach(steamId => {if (this.client.myFriends[steamId] === SteamUser.Steam.EFriendRelationship.RequestRecipient) {logger.info(`Friend request while offline from: ${steamId}`);this.client.addFriend(steamId, (err, name) => {if (err) {return logger.error(`Cannot add friend: ${err}`)}logger.info(`Added ${name} as a friend.`);});this.client.chatMessage(steamId, `Thanks for adding me! Type '!help' for commands.`);};});});this.client.on('offlineMessages', (count, friends) => {logger.info(`${count} messages from ${friends} since your last login.`)});}; Now, above line 5 I want to do something like(pseudo-code) if (this.client.myFriends[steamId] == steamid.isPrivate) { declineFriendship();} Is there any way to achieve this? Couldn't find anything in the wiki / docs.Many thanks and thanks for all the hard work that went into this project. Edited February 15, 2018 by justarandomdeveloper Quote
Vanilla Posted February 15, 2018 Report Posted February 15, 2018 Try using steamcommunity getSteamUser, and check their privacyStatehttps://github.com/DoctorMcKay/node-steamcommunity/wiki/SteamCommunity#getsteamuserid-callback Maybe also possible using getPersona, but I don't know anything about ithttps://github.com/DoctorMcKay/node-steam-user#getpersonassteamids-callback Quote
justarandomdeveloper Posted February 15, 2018 Author Report Posted February 15, 2018 Hey @Vanilla. Solved it with getSteamUser Thanks for the help. Here's my code if anyone wants to reference it in the future: checkFriendsAndMessagesWhileOffline() {this.client.on('friendsList', () => {let friendcount = 0;Object.keys(this.client.myFriends).forEach(steamId => {if (this.client.myFriends[steamId] === SteamUser.Steam.EFriendRelationship.RequestRecipient) {logger.info(`Friend request while offline from: ${steamId}`);this.community.getSteamUser(steamId, (err, user) => {if (err) {return logger.error(`Cannot get user: ${err}`)}if (user && (user.privacyState == "private" || user.privacyState == "friendsonly")) {return logger.warn(`User ${user.name} is private. Aborting...`);}logger.debug(`Profile is not private. Adding...`)this.client.addFriend(steamId, (err, name) => {if (err) {return logger.error(`Cannot add friend: ${err}`)}logger.info(`Added ${name} as a friend.`);});this.client.chatMessage(steamId, `Thanks for adding! Type '!help' for commands.`);});};});});this.client.on('offlineMessages', (count, friends) => {logger.info(`${count} messages from ${friends} since your last login.`)});}; 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.