Deleting own message is logged in the audit log

(#413) Bug Awaiting confirmation moderation

Thread

Comment by @cproudlock
RexSystem 1 vote originally by @cproudlock on GitHub
I looked into this — the fix is straightforward. In packages/api/src/channel/services/message/MessageDeleteService.tsx line 117, the audit log entry is created unconditionally for all guild message deletions:
if (channel.guildId) {
    await this.guildAuditLogService
        .createBuilder(channel.guildId, userId)
        .withAction(AuditLogActionType.MESSAGE_DELETE, message.id.toString())
        // ...
The fix is to add a check so self-deletions are skipped:
if (channel.guildId && message.authorId !== userId) {
The bulkDeleteMessages method correctly always logs since it requires MANAGE_MESSAGES permission (admin action), so that one should stay as-is.