-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate moderator logs from event logs #36
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// * Audit logs will not show up at the same time the message delete event | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
|
||
const auditLogs = await guild.fetchAuditLogs({ | ||
type: AuditLogEvent.MessageDelete, | ||
limit: 5 | ||
}); | ||
const auditLogEntry = auditLogs.entries.find(entry => | ||
entry.target.id === message.author.id && | ||
entry.extra.channel.id === message.channelId && | ||
Date.now() - entry.createdTimestamp < 5 * 60 * 1000 | ||
); | ||
// * This large time range is needed because message delete audit log entries are combined if multiple deletions are | ||
// * performed with the same target user, executor, and channel within 5 minutes. Decreasing this time range would | ||
// * create a risk of false negatives because the combined entry keeps the timestamp of the first deletion. | ||
// ! Edge case: If a user deletes their own message after a moderator deletes one of theirs within 5 minutes and in | ||
// ! the same channel, there will be a false positive mod log entry. | ||
|
||
const isDeletedByModerator = auditLogEntry !== undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree with your original message about this not being super great. This looks like it would be very error prone in large servers like ours where tons of messages are deleted all the time. I'm not sure this is worth keeping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone back and forth on this. I think that it is worth trying out, but if the edge case is hit often enough that it causes a significant amount of confusion, it should be removed. I don't know how common it is for users to delete their own messages within 5 minutes of one of theirs getting deleted by a mod.
313701f
to
dddc818
Compare
Resolves #34
Changes:
This creates a setting for a mod-log channel, which will log moderator events like punishments and slow-mode configuration. The event-log channel will continue to log user events like message updates and deletions.
Message deletions?
I originally wanted to move moderator-deleted messages into the mod-logs channel, but there are a few issues with this.
This PR is a draft because a decision on how to handle message deletions has not been made yet.Moderator message deletions have been implemented, with certain pitfalls as noted in a comment.