From 1ca256cd1fc8aefafc05752b8a9097dbc5fcaf21 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 1 Jan 2022 23:37:40 -0700 Subject: [PATCH] fix some really bad code practice --- events/messageCreate.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/events/messageCreate.js b/events/messageCreate.js index 83ebcec..7354cb1 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -60,17 +60,19 @@ module.exports = async (client, message) => { } if (message.guild && client.misc.cache.lxp.enabled.includes(message.guild.id)) { - LXP.findOne({gid: message.guild.id}).then(xp => { - if (!client.misc.cache.lxp.xp[message.guild.id]) {client.misc.cache.lxp.xp[message.guild.id] = {};} - if (!client.misc.cache.lxp.xp[message.guild.id][message.author.id]) {client.misc.cache.lxp.xp[message.guild.id][message.author.id] = { - xp: xp.xp[message.author.id] ? xp.xp[message.author.id][0] : 0, - level: xp.xp[message.author.id] ? xp.xp[message.author.id][1] : 1, - lastXP: new Date().getTime() - 60000 - };} - if (new Date().getTime() - client.misc.cache.lxp.xp[message.guild.id][message.author.id].lastXP > 60000) { - require('../util/lxp/gainxp')(client, message.member.id, message.channel); - } - }); + if (!client.misc.cache.lxp.xp[message.guild.id]) {client.misc.cache.lxp.xp[message.guild.id] = {};} + if (!client.misc.cache.lxp.xp[message.guild.id][message.author.id]) { + LXP.findOne({gid: message.guild.id}).then(xp => { + client.misc.cache.lxp.xp[message.guild.id][message.author.id] = { + xp: xp.xp[message.author.id] ? xp.xp[message.author.id][0] : 0, + level: xp.xp[message.author.id] ? xp.xp[message.author.id][1] : 1, + lastXP: new Date().getTime() - 60000 + }; + }); + } + if (new Date().getTime() - client.misc.cache.lxp.xp[message.guild.id][message.author.id].lastXP > 60000) { + require('../util/lxp/gainxp')(client, message.member.id, message.channel); + } } if (!client.misc.cache.monners[message.author.id]) {