woomy/src/events/messageUpdate.js

42 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2020-01-25 10:02:43 +00:00
const Discord = require("discord.js");
module.exports = (client, omsg, nmsg) => {
if (nmsg.content === omsg.content) return;
const settings = (omsg.settings = nmsg.settings = client.getSettings(
nmsg.guild.id
));
if (settings.chatlogsChannel !== "off") {
2020-03-09 01:11:33 +00:00
const channel = nmsg.guild.channels.cache.find(
2020-01-25 10:02:43 +00:00
channel => channel.name === settings.chatlogsChannel
);
if (channel) {
2021-04-03 04:13:08 +00:00
if (!nmsg.member) return;
2020-03-09 01:11:33 +00:00
let embed = new Discord.MessageEmbed();
2020-01-25 10:02:43 +00:00
embed.setColor("#fff937");
2020-03-09 01:11:33 +00:00
embed.setAuthor("Message Edited!", nmsg.member.user.avatarURL({dynamic: true}));
2020-01-25 10:02:43 +00:00
if (omsg.content == "") {
omsg.content = "**[IMAGE]**"
} else if (nmsg.content == "") {
nmsg.content = `**[IMAGE]**`
} else {
omsg.content = `\`${omsg.content}\``
nmsg.content = `\`${nmsg.content}\``
}
if(omsg.content.length + nmsg.content.length + nmsg.member.user.username.length + nmsg.member.user.id.length + nmsg.channel.name.length + 2 > 2048) {
return;
}
embed.setDescription(`[Jump to message](https://discord.com/channels/${nmsg.guild.id}/${nmsg.channel.id}/${nmsg.id})\n• Author: ${nmsg.member} (${nmsg.member.user.id})\n• Channel: ${nmsg.channel}\n• Old message: ${omsg.content}\n• New message: ${nmsg.content}`)
2020-01-25 10:02:43 +00:00
try {
channel.send({ embed });
} catch (err) {
// probably no permissions to send messages/embeds there
};
};
};
};