Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function joinGroups () {
const groups = config.get('groups');
const relations = client.myGroups;
for (let i = 0; i < groups.length; i++) {
const id = groups[i];
let relation = SteamUser.EClanRelationship.None;
for (const group in relations) {
if (id != group) {
continue;
}
relation = relations[group];
}
if (relation != SteamUser.EClanRelationship.Member) {
joinGroup(id);
}
}
}
const groups = config.get('groups');
const relations = client.myGroups;
for (let i = 0; i < groups.length; i++) {
const id = groups[i];
let relation = SteamUser.EClanRelationship.None;
for (const group in relations) {
if (id != group) {
continue;
}
relation = relations[group];
}
if (relation != SteamUser.EClanRelationship.Member) {
joinGroup(id);
}
}
}
groups.forEach(function (steamID) {
if (client.myGroups[steamID] !== SteamUser.EClanRelationship.Member && client.myGroups[steamID] !== SteamUser.EClanRelationship.Blocked) {
community.getSteamGroup(new SteamID(steamID), function (err, group) {
if (err) {
log.warn('Failed to get group: ', err);
return;
}
log.info('Not member of group "' + group.name + ' ("' + steamID + '"), joining...');
group.join(function (err) {
if (err) {
log.warn('Failed to join group: ', err);
}
});
});
}
});
};
exports.groupRelationChanged = function (steamID, relationship) {
log.debug('Group relation changed', { steamID: steamID, relationship: relationship });
if (relationship === SteamUser.EClanRelationship.Invited) {
const join = groups.indexOf(steamID.getSteamID64()) === -1;
log.info('Got invited to group ' + steamID.getSteamID64() + ', ' + (join ? 'accepting...' : 'declining...'));
client.respondToGroupInvite(steamID, groups.indexOf(steamID.getSteamID64()) === -1);
} else if (relationship === SteamUser.EClanRelationship.Member) {
log.info('Joined group ' + steamID.getSteamID64());
}
};