diff --git a/bot.js b/bot.js index 41074a9..15ef176 100644 --- a/bot.js +++ b/bot.js @@ -31,7 +31,8 @@ client.misc = { lxp: { enabled: [], xp: {}, - hasLevelRoles: [] + hasLevelRoles: [], + disabledChannels: new Map() }, monit: {}, monitEnabled: [], diff --git a/events/messageCreate.js b/events/messageCreate.js index 7354cb1..92686fa 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -60,18 +60,20 @@ module.exports = async (client, message) => { } if (message.guild && client.misc.cache.lxp.enabled.includes(message.guild.id)) { - 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.lxp.disabledMessages.has(message.guild.id) || !client.misc.cache.lxp.disabledMessage.get(message.guild.id).includes(message.channel.id)) { + 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); + } } } diff --git a/models/localxp.js b/models/localxp.js index cd4b995..35e4a9d 100644 --- a/models/localxp.js +++ b/models/localxp.js @@ -4,7 +4,9 @@ const lxp = new mongoose.Schema({ gid: {type: String, unique: true}, msg: {type: Boolean, default: true}, xp: {type: Object, default: {}}, - lvch: {type: String, default: ''} + lvch: {type: String, default: ''}, + chests: {type: Object}, + noGains: {type: [String]} }); module.exports = mongoose.model('localxp', lxp); \ No newline at end of file diff --git a/util/cache/lxp.js b/util/cache/lxp.js index 3c9e1b9..97be344 100644 --- a/util/cache/lxp.js +++ b/util/cache/lxp.js @@ -2,8 +2,10 @@ const LXP = require('../../models/localxp'); module.exports = async client => { client.misc.cache.lxp.enabled = []; + client.misc.cache.lxp.disabledChannels = new Map(); for await (const xp of LXP.find()) { client.misc.cache.lxp.enabled.push(xp.gid); + if (xp.noGains && xp.noGains.length) {client.misc.cache.lxp.disabledChannels.set(xp.gid, xp.noGains);} } }; \ No newline at end of file