master
Kit Kasune 3 years ago
parent 22cf92fe0c
commit a99229733c
  1. 49
      commands/leveling/ignorexp.js
  2. 2
      commands/misc/ingorear.js
  3. 5
      events/messageCreate.js

@ -0,0 +1,49 @@
const Discord = require('discord.js');
const LXP = require('../../models/localxp');
const GuildData = require('../../models/guild');
module.exports = {
name: "ignorexp",
aliases: ['xpignore', 'noxp'],
meta: {
category: 'Leveling',
description: "Stop XP from being gained in a specific channel.",
syntax: '`ignorexp [#channel|channelId]`',
extra: null,
guildOnly: true
},
help: new Discord.MessageEmbed()
.setTitle("Help -> AR Ignoring")
.setDescription("Provide a channel (or don't to use the current channel) to be voided from auto-responses, that way the responses won't send in places you don't want them to.")
.addField("Syntax", "`[#channel|channelId]` - channel is optional."),
async execute(message, msg, args, cmd, prefix, mention, client) {
const tg = await GuildData.findOne({gid: message.guild.id});
if ((!tg || !tg.staffrole || !tg.staffrole.length || !message.member.roles.cache.has(tg.staffrole)) && !message.member.permissions.has("ADMINISTRATOR")) {return message.channel.send("You must have the staff role or be an administrator in this server in order to edit XP settings.");}
let txp = await LXP.findOne({gid: message.guild.id});
if (!txp) {return message.channel.send("This server doesn't have XP enabled.");}
let ch;
if (args[1]) {
ch = message.mentions.channels.first() || message.guild.channels.cache.get(args[1]);
if (!ch) {return message.channel.send("I couldn't find that channel. Please try again!");}
} else {ch = message.channel;}
ch = ch.id;
if (!txp.noGains) {txp.noGains = [];}
if (txp.noGains.includes(ch)) {
let ti = txp.noGains;
ti.splice(ti.indexOf(ch), 1);
txp.noGains = ti;
txp.markModified('noGains');
txp.save();
client.misc.cache.lxp.disabledChannels.set(message.guild.id, txp.noGains);
return message.channel.send("Got it. I'll start giving people XP here from now on.");
} else {
txp.noGains.push(ch);
txp.save();
client.misc.cache.lxp.disabledChannels.set(message.guild.id, txp.noGains);
return message.channel.send("I'll stop giving people XP in this channel from now on.");
}
}
};

@ -19,7 +19,7 @@ module.exports = {
.addField("Syntax", "`[#channel|channelId]` - channel is optional."), .addField("Syntax", "`[#channel|channelId]` - channel is optional."),
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
const tg = await GuildData.findOne({gid: message.guild.id}); const tg = await GuildData.findOne({gid: message.guild.id});
if ((!tg || !tg.staffrole || !tg.staffrole.length || !message.member.roles.cache.has(tg.staffrole) && !message.member.permissions.has("ADMINISTRATOR"))) {return message.channel.send("You must have the staff role or be an administrator in this server in order to edit AR settings.");} if ((!tg || !tg.staffrole || !tg.staffrole.length || !message.member.roles.cache.has(tg.staffrole)) && !message.member.permissions.has("ADMINISTRATOR")) {return message.channel.send("You must have the staff role or be an administrator in this server in order to edit AR settings.");}
let tar = await AR.findOne({gid: message.guild.id}); let tar = await AR.findOne({gid: message.guild.id});
if (!tar || !tar.triggers.length) {return message.channel.send("This server doesn't have any auto-responses. Try adding some first, then you can set some channels to be ignored.");} if (!tar || !tar.triggers.length) {return message.channel.send("This server doesn't have any auto-responses. Try adding some first, then you can set some channels to be ignored.");}

@ -60,7 +60,7 @@ module.exports = async (client, message) => {
} }
if (message.guild && client.misc.cache.lxp.enabled.includes(message.guild.id)) { 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.disabledChannels.has(message.guild.id) || !client.misc.cache.lxp.disabledChannels.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]) {client.misc.cache.lxp.xp[message.guild.id] = {};}
if (!client.misc.cache.lxp.xp[message.guild.id][message.author.id]) { if (!client.misc.cache.lxp.xp[message.guild.id][message.author.id]) {
LXP.findOne({gid: message.guild.id}).then(xp => { LXP.findOne({gid: message.guild.id}).then(xp => {
@ -69,9 +69,10 @@ module.exports = async (client, message) => {
level: xp.xp[message.author.id] ? xp.xp[message.author.id][1] : 1, level: xp.xp[message.author.id] ? xp.xp[message.author.id][1] : 1,
lastXP: new Date().getTime() - 60000 lastXP: new Date().getTime() - 60000
}; };
require('../util/lxp/gainxp')(client, message.member.id, message.channel);
}); });
} }
if (new Date().getTime() - client.misc.cache.lxp.xp[message.guild.id][message.author.id].lastXP > 60000) { else 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); require('../util/lxp/gainxp')(client, message.member.id, message.channel);
} }
} }

Loading…
Cancel
Save