Yea the comments are on public. But it tries to post the comment before the login. How to make to post the comment after login. This is the full code:
const SteamCommunity = require('steamcommunity');
let community = new SteamCommunity();
const config = require('./config.json')
var SteamUser = require('steam-user');
var client = new SteamUser();
client.logOn({
"accountName": config.username,
"password": config.password,
});
client.on('loggedOn', function(details) {
console.log("Logged into Steam as " + client.steamID.getSteam3RenderedID());
client.setPersona(SteamUser.EPersonaState.Online);
});
client.on('error', function(e) {
console.log('An error ocurred:')
console.log(e);
});
client.on("friendMessage", function(steamID, message) {
console.log("Friend message from " + steamID+ ": " + message);
if (message == "Ping") {
client.chatMessage(steamID, "Pong");
console.log("Send back: Pong");
}
else {
client.chatMessage(steamID, config.greetMsg);
console.log("Send back the standard reply");
}
});
function commentOnUserProfile(steamID, message) {
community.postUserComment(steamID, message, function(err) {
if(err) {
console.log(err);
} else {
console.log('Successfully commented: ' + message)
}
});
}
var user = config.toWho;
var message = config.comment;
commentOnUserProfile(user, message);