Then calling the getgroup function everytime someone messages you would help but probably slow down the response time but if you want to do it then this should work.
And you can remove the getGroup from loggedOn event.
function getGroup(groupName,callback) {
groupmembers = [];
community.getSteamGroup(groupName, (err, group) => {
if (err) {
console.log("Couldn't get the Group Retrying");
setTimeout((groupName) => { getGroup(groupName,callback) }, 5000);
} else group.getMembers((err, members) => {
if (err) {
console.log("Couldn't get the Group Retrying..");
setTimeout((groupName) => { getGroup(groupName,callback) }, 5000);
} else {
members.forEach(member => {
groupmembers.push(member.accountid);
});
callback(groupmembers);
console.log("Loaded The Group Members");
}
});
});
}
client.on("friendMessage", function (steamID, message) {
getGroup("yourGroupName",members => {
if (members.length > 0) {
if (message == "!test") {
if (members.includes(steamID.accountid)) {
client.chatMessage(steamID, "Test Message");
}
else client.chatMessage(steamID, "You have to join our steam group bla bla to use this bot or idk");
}
}
else {
client.chatMessage(steamID, "bot is still loading message");
}
});
});