Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenkii committed Mar 21, 2024
1 parent c89df44 commit d9ac109
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/jobs/manageMemberRoles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ export async function manageMemberRoles() {

} else {
const cid = await vatsimApiService.getCIDFromDiscordID(member[1].id);
await userService.addUser(member[1], cid);

if (cid) {
const vatgerApiData = await vatgerApiService.getUserDetailsFromVatger(cid);

await userService.updateUser(member[1], {cid: cid, isVatger: vatgerApiData.is_vatger_member});

}

}


Expand Down
2 changes: 1 addition & 1 deletion src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function updateUser(user: GuildMember, changes: Partial<UserDocument>) {

const changeOps = getValidUpdateOpsFromNestedObject(changes);

const userDocument = await userModel.findOneAndUpdate({ discordId: user.id }, { $set: changeOps }, { new: true }).exec();
const userDocument = await userModel.findOneAndUpdate({ discordId: user.id }, { $set: changeOps }, { new: true, upsert: true }).exec();

return userDocument
} catch (error) {
Expand Down

0 comments on commit d9ac109

Please sign in to comment.