From 81f1d78522f0fce17f0f9e820bf3581d246b559d Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Tue, 8 Dec 2020 11:12:46 -0700 Subject: [PATCH] Message edit logs --- events/messageDelete.js | 2 +- events/messageUpdate.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 events/messageUpdate.js diff --git a/events/messageDelete.js b/events/messageDelete.js index cf01bf4..5fc5f7a 100644 --- a/events/messageDelete.js +++ b/events/messageDelete.js @@ -22,6 +22,6 @@ module.exports = async (client, message) => { } if (as.length) {mde.addField('Attachments', as);} } - message.guild.channels.cache.get(ts).send(mde); + message.guild.channels.cache.get(ts).send(mde).catch(() => {}); }} } \ No newline at end of file diff --git a/events/messageUpdate.js b/events/messageUpdate.js new file mode 100644 index 0000000..89a942b --- /dev/null +++ b/events/messageUpdate.js @@ -0,0 +1,22 @@ +const Discord = require('discord.js'); + +module.exports = async (client, oldM, newM) => { + if (oldM.channel.type != "text") {return;}; + if (oldM.author.bot) {return;} + if (oldM.deleted) {return;} + //if (!Object.keys(snipe.edit).includes(oldM.guild.id)) {snipe.edit[oldM.guild.id] = {};}; + //snipe.edit[oldM.guild.id][oldM.channel.id] = {old: oldM, cur: newM}; + + let ts = client.guildconfig.logs.has(oldM.guild.id) && client.guildconfig.logs.get(oldM.guild.id).has('medit') ? client.guildconfig.logs.get(oldM.guild.id).get('medit') : null; + if (ts) {if (oldM.guild.channels.cache.has(ts) && oldM.guild.channels.cache.get(ts).permissionsFor(client.user.id).has("SEND_oldMS")) { + let embed = new Discord.MessageEmbed() + .setTitle('Message Edited') + .setDescription(`Sent by <@${oldM.author.id}> | In <#${oldM.channel.id}> | [See Message](${oldM.url})`) + .setThumbnail(oldM.author.avatarURL({size: 1024})) + .addField("Old Message", "`-> `" + oldM.content.toString()) + .addField("New Message", "`-> `" + newM.content.toString()) + .setColor('8034eb').setFooter("Natsuki", client.user.avatarURL()).setTimestamp(); + if (newM.attachments.size && ['.png', '.jpg', '.gif'].includes(newM.attachments.first().url.slice(newM.attachments.first().url.length - 4, newM.attachments.first().url.length))) {embed.setImage(newM.attachments.first().url);} + oldM.guild.channels.cache.get(ts).send(embed).catch(() => {}); + }} +} \ No newline at end of file