JaBa/events/Monitoring/messageUpdate.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-07-03 19:30:47 +05:00
const { EmbedBuilder } = require("discord.js"),
BaseEvent = require("../../base/BaseEvent");
class messageUpdate extends BaseEvent {
constructor() {
super({
name: "messageUpdate",
once: false,
});
}
/**
*
2023-07-31 22:09:27 +05:00
* @param {import("../../base/JaBa")} client The Discord client
* @param {import("discord.js").Message} oldMessage The message before the update
* @param {import("discord.js").Message} newMessage The message after the update
2023-07-03 19:30:47 +05:00
*/
async execute(client, oldMessage, newMessage) {
if (oldMessage.guild && oldMessage.guildId === "568120814776614924") return;
if (oldMessage.author.bot) return;
if (oldMessage.content === newMessage.content) return;
2023-10-15 15:05:10 +05:00
const guildData = await client.findOrCreateGuild(oldMessage.guildId);
2023-07-03 19:30:47 +05:00
2023-07-10 21:02:38 +05:00
if (guildData.plugins?.monitoring?.messageUpdate) {
2023-07-03 19:30:47 +05:00
const embed = new EmbedBuilder()
.setAuthor({
name: newMessage.author.getUsername(),
iconURL: newMessage.author.displayAvatarURL(),
})
.setColor(client.config.embed.color)
.setFooter(client.config.embed.footer)
2023-07-03 19:30:47 +05:00
.setTitle(`${newMessage.author.getUsername()} edited a message!`)
.setDescription(`Old Message: \`\`\`${oldMessage.content}\`\`\`\nNew Message: \`\`\`${newMessage.content}\`\`\`\nJump to message: ${newMessage.url}`);
newMessage.guild.channels.cache.get(guildData.plugins.monitoring.messageUpdate).send({
embeds: [embed],
});
}
}
}
2023-07-05 00:58:06 +05:00
module.exports = messageUpdate;