Skip to content

Commit

Permalink
Update message_delete_EVT.js
Browse files Browse the repository at this point in the history
Add support for DMs
  • Loading branch information
GoodOne120 committed Sep 25, 2024
1 parent 04bfc88 commit b3a5504
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions events/message_delete_EVT.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ module.exports = {
DBM.Events.messageDeleted = async function messageDeleted(message) {
if (!Bot.$evts['Message Delete MOD']) return;
const server = message.guild;
if (!server) return;
let executor = undefined;
if (server) {
const auditLogs = await message.guild.fetchAuditLogs({
limit: 1,
type: 'MESSAGE_DELETE',
});

const auditLogs = await message.guild.fetchAuditLogs({
limit: 1,
type: 'MESSAGE_DELETE',
});

const deletionAuditLogs = auditLogs.entries.first();
console.log(deletionAuditLogs);

let executor;
if (!deletionAuditLogs) {
executor = undefined;
} else if (deletionAuditLogs.target.id === message.author.id) {
executor = deletionAuditLogs.executor;
} else {
executor = message.author;
const deletionAuditLogs = auditLogs.entries.first();
if (!deletionAuditLogs) {
executor = undefined;
} else if (deletionAuditLogs.target.id === (message.author ? message.author.id : undefined)) {
executor = deletionAuditLogs.executor;
} else {
executor = message.author;
}
}

for (const event of Bot.$evts['Message Delete MOD']) {
Expand All @@ -39,7 +37,7 @@ module.exports = {
};

const { onReady } = Bot;
Bot.onReady = function messageReactionAddedOnReady(...params) {
Bot.onReady = function messageDeletedOnReady(...params) {
Bot.bot.on('messageDelete', DBM.Events.messageDeleted);
onReady.apply(this, ...params);
};
Expand Down

0 comments on commit b3a5504

Please sign in to comment.