no drifting timestamps
This commit is contained in:
4
db.ts
4
db.ts
@@ -177,10 +177,10 @@ export async function edit_role_income(role_income_obj: RoleIncome) {
|
|||||||
return await role_income.replaceOne({ role: role_income_obj.role }, role_income_obj);
|
return await role_income.replaceOne({ role: role_income_obj.role }, role_income_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function update_role_income_last_claim(role: string) {
|
export async function update_role_income_last_claim(role: string, last_claim: number, hours: number, cycles: number) {
|
||||||
return await role_income.updateOne({ role }, {
|
return await role_income.updateOne({ role }, {
|
||||||
$set: {
|
$set: {
|
||||||
last_claim: Date.now(),
|
last_claim: last_claim + hours * cycles * 60 * 60 * 1000,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export default function main(client: Client) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//then update db with new latest claim time
|
//then update db with new latest claim time
|
||||||
await update_role_income_last_claim(role_income.role);
|
await update_role_income_last_claim(role_income.role, role_income.last_claim, role_income.hours, cycles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
role_income_poll();
|
role_income_poll();
|
||||||
|
|||||||
Reference in New Issue
Block a user