Hey, Running into a bit of an issue sometimes with persona_state, it's sometimes null for some reason. Code:
Bot.prototype.sendMessage = function(steam_id, send_offline, message) {
if (this.client.myFriends[steam_id] === undefined || this.client.myFriends[steam_id] === 2 || this.client.myFriends[steam_id] === 4) {
log.error(this.data.name, 'The message recipient is not a friend.');
return false;
}
this.client.getPersonas([steam_id], (personas) => {
if (send_offline == false && personas[steam_id].persona_state == 0) {
log.info(this.data.name, 'The recipient is offline, and the request has disabled offline sending.');
return false;
} else {
// temp. debug
log.info(this.data.name, 'Name: ' + personas[steam_id].player_name + ', State: ' + personas[steam_id].persona_state);
}
log.info(this.data.name, 'Sending the message...');
this.client.chatMessage(steam_id, message);
log.success(this.data.name, 'Success!');
return true;
});
};
What could cause this? The player it tries to send the message to is a friend, so that's not the issue.