ignoring channels for xp gain

master
Kit Kasune 3 years ago
parent 1ca256cd1f
commit 22cf92fe0c
  1. 3
      bot.js
  2. 2
      events/messageCreate.js
  3. 4
      models/localxp.js
  4. 2
      util/cache/lxp.js

@ -31,7 +31,8 @@ client.misc = {
lxp: {
enabled: [],
xp: {},
hasLevelRoles: []
hasLevelRoles: [],
disabledChannels: new Map()
},
monit: {},
monitEnabled: [],

@ -60,6 +60,7 @@ module.exports = async (client, message) => {
}
if (message.guild && client.misc.cache.lxp.enabled.includes(message.guild.id)) {
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 => {
@ -74,6 +75,7 @@ module.exports = async (client, message) => {
require('../util/lxp/gainxp')(client, message.member.id, message.channel);
}
}
}
if (!client.misc.cache.monners[message.author.id]) {
let tmonners = await Monners.findOne({uid: message.author.id}) || new Monners({uid: message.author.id});

@ -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);

2
util/cache/lxp.js vendored

@ -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);}
}
};
Loading…
Cancel
Save