Jump to content
McKay Development

Recommended Posts

Posted (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 by justarandomdeveloper
Posted

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.`)
});
};

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...
×
×
  • Create New...