2024-02-06 21:45:53 +05:00
|
|
|
const BaseEvent = require("../../base/BaseEvent");
|
2023-07-31 22:09:27 +05:00
|
|
|
|
|
|
|
class messageDelete extends BaseEvent {
|
|
|
|
constructor() {
|
|
|
|
super({
|
|
|
|
name: "messageDelete",
|
|
|
|
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} message The deleted message
|
|
|
|
*/
|
|
|
|
async execute(client, message) {
|
|
|
|
if (message.guild && message.guildId === "568120814776614924") return;
|
|
|
|
if (message.author.bot) return;
|
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
const guildData = message.data.guild;
|
2023-07-31 22:09:27 +05:00
|
|
|
|
|
|
|
if (guildData.plugins?.monitoring?.messageDelete) {
|
2024-07-17 20:30:01 +05:00
|
|
|
await client.wait(1000);
|
|
|
|
|
|
|
|
const logs = await message.guild.fetchAuditLogs({
|
|
|
|
limit: 5,
|
|
|
|
type: "MESSAGE_DELETE",
|
|
|
|
});
|
|
|
|
|
|
|
|
const deletedMessage = logs.entries.find(e => e.targetId === message.author.id && e.extra.channel.id && Date.now() - e.createdTimestamp < 20000);
|
|
|
|
|
2024-02-06 21:45:53 +05:00
|
|
|
const embed = client.embed({
|
|
|
|
author: {
|
2023-07-31 22:09:27 +05:00
|
|
|
name: message.author.getUsername(),
|
|
|
|
iconURL: message.author.displayAvatarURL(),
|
2024-02-06 21:45:53 +05:00
|
|
|
},
|
2024-02-13 23:19:27 +05:00
|
|
|
title: message.translate("misc:MONITORING:DELETE:TITLE", { user: message.author.getUsername() }),
|
2024-07-17 20:30:01 +05:00
|
|
|
description: message.translate("misc:MONITORING:DELETE:DESCRIPTION", { deletedBy: deletedMessage.executor ? deletedMessage.executor.toString() : "Unknown", content: message.content, channel: message.channel.toString(), time: `<t:${Math.floor(message.createdTimestamp / 1000)}:f>` }),
|
2024-02-06 21:45:53 +05:00
|
|
|
});
|
2023-07-31 22:09:27 +05:00
|
|
|
|
|
|
|
message.guild.channels.cache.get(guildData.plugins.monitoring.messageDelete).send({
|
|
|
|
embeds: [embed],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = messageDelete;
|