shaxu
shaxu
DIAdiscord.js - Imagine an app
Created by shaxu on 7/17/2023 in #djs-questions
Catch deleted messages with Events.GuildAuditLogEntryCreate
Hi, I have problem with this code. As you can see on video it logs only one random message when it wants and when rest of the messages are deleted it doesn't work.
bot.on(Events.GuildAuditLogEntryCreate, async auditLog => {

console.log("Delete check")

const { action, extra: channel, executorId, targetId } = auditLog;

if ( action !== AuditLogEvent.MessageDelete ) return;

const executor = await bot.users.fetch(executorId);

const target = await bot.users.fetch(targetId);

console.log(`A message by ${target.tag} was deleted by ${executor.tag} in ${channel}.`);
});
bot.on(Events.GuildAuditLogEntryCreate, async auditLog => {

console.log("Delete check")

const { action, extra: channel, executorId, targetId } = auditLog;

if ( action !== AuditLogEvent.MessageDelete ) return;

const executor = await bot.users.fetch(executorId);

const target = await bot.users.fetch(targetId);

console.log(`A message by ${target.tag} was deleted by ${executor.tag} in ${channel}.`);
});
10 replies