fix logs and vc logs

master
Kit Kasune 4 years ago
parent d6548bccac
commit 507b5baa1b
  1. 22
      commands/moderation/logs.js
  2. 21
      events/voiceStateUpdate.js
  3. 24
      models/log.js

@ -10,8 +10,7 @@ const ObjLogTypes = {
chnew: ['chn', 'chc', 'newch', 'newchannel', 'chcreate', 'channelcreate'], chnew: ['chn', 'chc', 'newch', 'newchannel', 'chcreate', 'channelcreate'],
//chedit: ['channeledit'], //chedit: ['channeledit'],
chdelete: ['chd', 'channeldelete', 'deletechannel', 'deletech', 'chdelete'], chdelete: ['chd', 'channeldelete', 'deletechannel', 'deletech', 'chdelete'],
//vcjoin: [], vc: ['voice', 'vc'],
//vcleave: [],
//servervcmute: [], //servervcmute: [],
//servervcdeafen: [], //servervcdeafen: [],
//kick: [], //kick: [],
@ -62,15 +61,16 @@ module.exports = {
if (!ch) {return message.channel.send("I can't find that channel! Make sure that you've mentioned one, or that the ID you provided is correct, and that I can see it.");} if (!ch) {return message.channel.send("I can't find that channel! Make sure that you've mentioned one, or that the ID you provided is correct, and that I can see it.");}
if (!ch.permissionsFor(client.user.id).has("SEND_MESSAGES")) {return message.reply("I don't have permissions to send messages in that channel. Please give me access and try again.");} if (!ch.permissionsFor(client.user.id).has("SEND_MESSAGES")) {return message.reply("I don't have permissions to send messages in that channel. Please give me access and try again.");}
let tl = await LogData.findOne({gid: message.guild.id}) || new LogData({gid: message.guild.id}); let tl = await LogData.findOne({gid: message.guild.id}) || new LogData({gid: message.guild.id});
tl[lt] = ch.id; tl.logs[lt] = ch.id;
tl.markModified(`logs.${lt}`);
tl.save(); tl.save();
if (!client.guildconfig.logs.has(message.guild.id)) {client.guildconfig.logs.set(message.guild.id, new Map());} if (!client.guildconfig.logs.has(message.guild.id)) {client.guildconfig.logs.set(message.guild.id, new Map());}
client.guildconfig.logs.get(message.guild.id).set(lt, ch.id); client.guildconfig.logs.get(message.guild.id).set(lt, ch.id);
return message.channel.send("Log settings updated!") return message.channel.send("Log settings updated!");
} }
if (['l', 'list'].includes(args[0].toLowerCase())) { if (['l', 'list'].includes(args[0].toLowerCase())) {
return message.channel.send("Valid log types:\n\n-`msgdelete` - Shows the content of a message that was deleted, in any channel.\n-`msgedit` - Shows both the old and new versions of a message when it is edited."); return message.channel.send("Valid log types:\n\n-`msgdelete` - Shows the content of a message that was deleted, in any channel.\n-`msgedit` - Shows both the old and new versions of a message when it is edited.\n-`vc` - Logs when members join and leave VCs.");
} }
if (['v', 'view'].includes(args[0].toLowerCase())) { if (['v', 'view'].includes(args[0].toLowerCase())) {
@ -79,7 +79,17 @@ module.exports = {
} }
if (['c', 'clear'].includes(args[0].toLowerCase())) { if (['c', 'clear'].includes(args[0].toLowerCase())) {
let tl = await LogData.findOne({gid: message.guild.id});
if (!tl) {return message.channel.send("Your server doesn't have any logs set up!");}
const conf = await require('../../util/ask')(message, "Are you sure you want to clear all your server's logs settings? This cannot be undone.", 60000);
if (!conf) {return;}
if (!['y', 'yes', 'sure'].includes(`${conf}`.toLowerCase())) {return message.channel.send("Okay, I won't clear your logs settings.");}
return LogData.deleteOne({gid: message.guild.id})
.then(() => {
client.guildconfig.logs.delete(message.guild.id);
return message.channel.send("Logs settings wiped!")
})
.catch(() => message.channel.send("An error occurred, and your logs data wasn't deleted. Please contact my devs if the problem persists."));
} }
} }
}; };

@ -1,6 +1,27 @@
const Discord = require("discord.js");
const Monitor = require('../models/monitor'); const Monitor = require('../models/monitor');
module.exports = async (client, oldState, voice) => { module.exports = async (client, oldState, voice) => {
let ts = client.guildconfig.logs.has(voice.guild.id) && client.guildconfig.logs.get(voice.guild.id).has('vc') ? client.guildconfig.logs.get(voice.guild.id).get('vc') : null;
if (ts) {if (voice.guild.channels.cache.has(ts) && voice.guild.channels.cache.get(ts).permissionsFor(client.user.id).has("SEND_MESSAGES")) {
if (oldState.channelID && voice.channelID) {
voice.guild.channels.cache.get(ts).send(new Discord.MessageEmbed()
.setTitle(`Member Switched VCs`)
.setThumbnail(client.users.cache.get(oldState.member.id).avatarURL({size: 2048, dynamic: true}))
.setDescription(`Old Channel: **${oldState.channel.name}**\nNew Channel: **${voice.channel.name}**`)
.setColor('e86b8f').setFooter("Natsuki", client.user.avatarURL()).setTimestamp()
).catch(() => {});
} else {
voice.guild.channels.cache.get(ts).send(new Discord.MessageEmbed()
.setTitle(`Member ${voice.channelID ? 'Joined' : 'Left'} VC`)
.setThumbnail(client.users.cache.get(oldState.member.id).avatarURL({size: 2048, dynamic: true}))
.setDescription(`Channel: **${voice.channelID ? voice.channel.name : oldState.channel.name}**`)
.setColor('e86b8f').setFooter("Natsuki", client.user.avatarURL()).setTimestamp()
).catch(() => {});
}
}}
if (client.users.cache.get(voice.member.id).bot) {return;} if (client.users.cache.get(voice.member.id).bot) {return;}
if (voice.guild && client.misc.cache.monitEnabled.includes(voice.guild.id)) { if (voice.guild && client.misc.cache.monitEnabled.includes(voice.guild.id)) {
if (voice.channelID) { if (voice.channelID) {

@ -2,29 +2,7 @@ const mongoose = require('mongoose');
const logSchema = new mongoose.Schema({ const logSchema = new mongoose.Schema({
gid: {type: String, unique: true}, gid: {type: String, unique: true},
mdelete: {type: String, default: ''}, logs: {type: Object, default: {}}
medit: {type: String, default: ''},
chnew: {type: String, default: ''},
chedit: {type: String, default: ''},
chdelete: {type: String, default: ''},
vcjoin: {type: String, default: ''},
vcleave: {type: String, default: ''},
servervcmute: {type: String, default: ''},
servervcdeafen: {type: String, default: ''},
kick: {type: String, default: ''},
ban: {type: String, default: ''},
mute: {type: String, default: ''},
warn: {type: String, default: ''},
giverole: {type: String, default: ''},
takerole: {type: String, default: ''},
addrole: {type: String, default: ''},
editrole: {type: String, default: ''},
deleterole: {type: String, default: ''},
serverjoin: {type: String, default: ''},
serverleave: {type: String, default: ''},
nickname: {type: String, default: ''},
username: {type: String, default: ''},
avatar: {type: String, default: ''}
}); });
module.exports = mongoose.model('log', logSchema); module.exports = mongoose.model('log', logSchema);
Loading…
Cancel
Save