JaBa/events/Monitoring/messageUpdate.js

46 lines
1.4 KiB
JavaScript
Raw Normal View History

const BaseEvent = require("../../base/BaseEvent");
2023-07-03 19:30:47 +05:00
class messageUpdate extends BaseEvent {
constructor() {
super({
name: "messageUpdate",
once: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client The Discord client
2023-07-31 22:09:27 +05:00
* @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.author.bot) return;
if (oldMessage.content === newMessage.content) return;
2024-02-09 23:26:57 +05:00
const guildData = newMessage.data.guild;
2023-07-03 19:30:47 +05:00
2023-07-10 21:02:38 +05:00
if (guildData.plugins?.monitoring?.messageUpdate) {
const embed = client.embed({
author: {
2023-07-03 19:30:47 +05:00
name: newMessage.author.getUsername(),
iconURL: newMessage.author.displayAvatarURL(),
},
2024-02-13 23:19:27 +05:00
title: newMessage.translate("misc:MONITORING:UPDATE:TITLE", { user: newMessage.author.getUsername() }),
2024-10-03 11:07:02 +05:00
description: newMessage.translate("misc:MONITORING:UPDATE:DESCRIPTION", {
oldContent: oldMessage.content,
newContent: newMessage.content,
url: newMessage.url,
}),
});
2023-07-03 19:30:47 +05:00
2024-10-03 11:07:02 +05:00
const monitoringChannelId = guildData.plugins.monitoring.messageUpdate;
const monitoringChannel = newMessage.guild.channels.cache.get(monitoringChannelId);
if (monitoringChannel) await monitoringChannel.send({ embeds: [embed] });
2023-07-03 19:30:47 +05:00
}
}
}
2023-07-05 00:58:06 +05:00
module.exports = messageUpdate;