Hello,
Before opening this post, I asked a few members in the Discord Developers server about the MessageDelete event. I'm having a strange issue: they told me that Discord doesn't provide logs when a bot deletes a message (unless the bot deletes a large number of messages).
However, when I run my code and log the data from the MessageDelete event, for some unknown reason, it shows my ID instead of the ID of the person who actually deleted it. Even stranger, the log claims the user who sent the message deleted it themselves, which is incorrect because the bot deleted it.
I'm here to ask for help and to understand this, because the data I'm receiving is very confusing. Here is the code I'm using to fetch the user:
const fetchedLogs = await guild.fetchAuditLogs({
type: AuditLogEvent.MessageDelete,
limit: 1,
});
const deletionLog = fetchedLogs.entries.first();
console.log("Valeur de deletionlog",deletionLog);
let executorTag = `<@${oldMessage.author.id}>`;
if (deletionLog) {
const { executor, targetId, createdTimestamp, extra } =
deletionLog;
const isRecent =
Math.abs(Date.now() - createdTimestamp) < 10_000;
const isCorrectTarget = targetId === oldMessage.author.id;
const isCorrectChannel =
extra?.channel?.id === oldMessage.channelId;
if (isRecent && isCorrectTarget && isCorrectChannel) {
executorTag = `<@${executor?.id}>`;
} else if (isRecent && isCorrectTarget) {
executorTag = `<@${executor?.id}>`;
}
}
Well for a strange reason he said the user in the data but the problem is that he log the wrong person who deleted i try and when the bot delete it he said that is the user who deleted it.
