UKF Posted May 8, 2016 Report Share Posted May 8, 2016 Hello,How can I add a friend if a friend request is received?I tried using addFriend(steamID), here's the code, am I doing something wrong? var SteamUser = require('steam-user'); var client = new SteamUser(); client.on("friend", function (steamID) { client.addFriend(steamID); } ); Thanks for the help!UKF Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 8, 2016 Report Share Posted May 8, 2016 https://github.com/DoctorMcKay/node-steam-user#friendrelationship Quote Link to comment Share on other sites More sharing options...
UKF Posted May 8, 2016 Author Report Share Posted May 8, 2016 https://github.com/DoctorMcKay/node-steam-user#friendrelationship I got it to work by using on('friendRelationship')If I'm not wrong, it should be client.on('friendRelationship'), function(parameters) { ... });Also, a question, these #paramaters, can be used such as client.on('parameter') etc...?And how could I get the the user's steam name? (not 64bit ID). Thank youUKF Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 8, 2016 Report Share Posted May 8, 2016 client.on('friendRelationship', function(steamID, relationship) { if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipient) { client.addFriend(steamID); } }); You can use getPersonas to get names and other profile data. UKF 1 Quote Link to comment Share on other sites More sharing options...
UKF Posted May 9, 2016 Author Report Share Posted May 9, 2016 Could you please show me how to use the getPersonas getter to get the name? Thank you Best regardsUKF Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 9, 2016 Report Share Posted May 9, 2016 The names are the player_name property in each object in the array provided in the callback. HolidayExplanation 1 Quote Link to comment Share on other sites More sharing options...
UKF Posted May 9, 2016 Author Report Share Posted May 9, 2016 The names are the player_name property in each object in the array provided in the callback. I am new into the callback things and not a professional I got this to work somehow: var botName; setInterval(function () { if (botName == undefined) { client.getPersonas([client.steamID], function (persona) { botName = persona[client.steamID].player_name; }); }}, 5000); Is it the right usage? Or is there a better way? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 9, 2016 Report Share Posted May 9, 2016 If you want your own profile name, just use the accountInfo property (and the accountInfo event). Quote Link to comment Share on other sites More sharing options...
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.