2020-11-07 17:01:03 +00:00
|
|
|
// Required components
|
2020-11-04 12:22:54 +00:00
|
|
|
const { event } = require('vylbot-core');
|
|
|
|
const { MessageEmbed } = require('discord.js');
|
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
// Event variables
|
2020-11-04 12:22:54 +00:00
|
|
|
const embedColor = "0x3050ba";
|
2021-02-17 18:12:45 +00:00
|
|
|
const logchannel = "message-logs";
|
2020-11-04 12:22:54 +00:00
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
// Event class
|
2020-11-04 12:22:54 +00:00
|
|
|
class messageupdate extends event {
|
|
|
|
constructor() {
|
2020-11-07 17:01:03 +00:00
|
|
|
// Set the event's run method
|
2020-11-04 12:22:54 +00:00
|
|
|
super("messageupdate");
|
|
|
|
}
|
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
// Run method
|
2020-11-04 12:22:54 +00:00
|
|
|
messageupdate(oldMessage, newMessage) {
|
2020-11-07 17:01:03 +00:00
|
|
|
// If the user is a bot or the content didn't change, return
|
2020-11-04 12:22:54 +00:00
|
|
|
if (newMessage.author.bot) return;
|
|
|
|
if (oldMessage.content == newMessage.content) return;
|
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
// Create an embed with the message's information
|
2021-02-17 18:12:45 +00:00
|
|
|
const embed = new MessageEmbed()
|
|
|
|
.setTitle("Message Edited")
|
2020-11-04 12:22:54 +00:00
|
|
|
.setColor(embedColor)
|
|
|
|
.addField("User", `${newMessage.author} \`${newMessage.author.tag}\``)
|
|
|
|
.addField("Channel", newMessage.channel)
|
|
|
|
.addField("Before", `\`\`\`${oldMessage.content || "*none*"}\`\`\``)
|
|
|
|
.addField("After", `\`\`\`${newMessage.content || "*none*"}\`\`\``)
|
|
|
|
.setThumbnail(newMessage.author.displayAvatarURL({ type: 'png', dynamic: true }));
|
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
// Send the embed into the log channel
|
2020-11-04 12:22:54 +00:00
|
|
|
newMessage.guild.channels.cache.find(channel => channel.name == logchannel).send(embed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 17:01:03 +00:00
|
|
|
module.exports = messageupdate;
|