3035129850591873351975 Posted August 9, 2023 Report Posted August 9, 2023 (edited) addFriend(steamID[, callback]) steamID - The SteamID of the user you want to add as a friend, as a SteamID object or a string that can parse into one callback - Optional. Called when Steam responds to this request. err - An Error object on failure, or null on success. If this is an Error object, it will have an eresult property. personaName - If successful, the current persona name of the user you added. Hello! I was looking for a solution for 2 days! But I didn't find any example. How can I SEND a friend request to a user - https://steamcommunity.com/profiles/76561198398979571 I made hundreds of examples but they don't work... I'm tired, please help! Edited August 9, 2023 by 3035129850591873351975 Quote
3035129850591873351975 Posted August 10, 2023 Author Report Posted August 10, 2023 I'm sorry, I started learning Java only 3 days ago. The last code, this is your example: client.on('friendRelationship', function(steamID, relationship) { if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipient) { client.addFriend(steamID); } }); I can't figure out where to write 76561198398979571 I didn't find any examples, videos or tutorials(( const SteamUser = require('steam-user') const config = require('./config.js') const client = new SteamUser; const logOnOptions = { accountName : config.accountName, password : config.password }; client.logOn(logOnOptions); client.on('loggedOn', () => { console.log(client.steamID + ' logged in Steam.'); client.setPersona(SteamUser.EPersonaState.Online); }); client.on('friendRelationship', function(steamID, relationship) { if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipient) { client.addFriend(steamID); } }); Quote
Dr. McKay Posted August 11, 2023 Report Posted August 11, 2023 That's an old example. SteamUser.Steam.EFriendRelationship.RequestRecipient should instead be SteamUser.EFriendRelationship.RequestRecipient. Regardless, if you want to initiate a friend request, use client.addFriend for that. For example, client.addFriend('76561198398979571') Quote
3035129850591873351975 Posted August 11, 2023 Author Report Posted August 11, 2023 I have tried many options, some of them are: client.on('friendRelationship', function(steamID, relationship) { if (relationship == SteamUser.EFriendRelationship.RequestRecipient) { client.addFriend('76561198398979571'); } }); client.addFriend('76561198398979571', function(steamID) { }); client.on('friendRelationship', function(sid, relationship) { if(relationship == 2) { client.addFriend('76561198398979571'); } }); client.on('friendRelationship', function(steamID, relationship) { if (steamID) { client.addFriend('76561198398979571'); } if (relationship == SteamUser.Steam.EFriendRelationship.RequestRecipient) { client.addFriend(steamID); } }); But none of the options work... I added an account check for bans. All is clear. client.on('accountLimitations', function (limited, communityBanned, locked, canInviteFriends) { if (limited) { console.log("Our account is limited. We cannot send friend invites, use the market, open group chat, or access the web API."); } if (communityBanned){ console.log("Our account is banned from Steam Community"); } if (locked){ console.log("Our account is locked. We cannot trade/gift/purchase items, play on VAC servers, or access Steam Community. Shutting down."); process.exit(1); } if (!canInviteFriends){ console.log("Our account is unable to send friend requests."); } }); I tried sending an invitation to other users. Does not work. Quote
Dr. McKay Posted August 11, 2023 Report Posted August 11, 2023 Your examples are only sending the invite if someone sends you an invite. That's what the friendRelationship event is for, running code when your friend relationship with someone changes. 3035129850591873351975 1 Quote
3035129850591873351975 Posted August 11, 2023 Author Report Posted August 11, 2023 client.on('friendsList', function (steamID) { client.addFriend('76561198398979571'); }); Thank you, it was really simple 😀 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.