parent
7a31a2e50a
commit
b71dc7b24d
@ -0,0 +1,19 @@ |
||||
const LXP = require('../../models/localxp'); |
||||
|
||||
module.exports = async (client) => { |
||||
let cd = new Date().getTime(); |
||||
await client.misc.cache.lxp.enabled.forEach(gxp => { |
||||
LXP.findOne({gid: gxp}).then(xp => { |
||||
if (!xp) {return;} |
||||
Object.keys(client.misc.cache.lxp.xp[gxp]).forEach(user => { |
||||
xp.xp[user] = [client.misc.cache.lxp.xp[gxp][user].xp, client.misc.cache.lxp.xp[gxp][user].level]; |
||||
xp.markModified(`xp.${user}`); |
||||
xp.save(); |
||||
if (cd - client.misc.cache.lxp.xp[gxp][user].lastXP > 600000) { |
||||
delete client.misc.cache.lxp.xp[gxp][user]; |
||||
if (!Object.keys(client.misc.cache.lxp.xp[gxp]).length) {delete client.misc.cache.lxp.xp[gxp];} |
||||
} |
||||
}); |
||||
}) |
||||
}) |
||||
}; |
Loading…
Reference in new issue