1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-18 16:03:36 +03:00

fix: handle case when audit log entries for message delete are empty

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2024-06-21 21:13:13 +05:00
parent 2b0c4b62d3
commit 1276451dc5
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -66,10 +66,10 @@ public sealed class MessageDeletedResponder : IResponder<IMessageDelete>
return ResultExtensions.FromError(auditLogResult);
}
var auditLog = auditLogPage.AuditLogEntries.Single();
var deleterResult = Result<IUser>.FromSuccess(message.Author);
if (auditLog.UserID is not null
var auditLog = auditLogPage.AuditLogEntries.SingleOrDefault();
if (auditLog is { UserID: not null }
&& auditLog.Options.Value.ChannelID == gatewayEvent.ChannelID
&& DateTimeOffset.UtcNow.Subtract(auditLog.ID.Timestamp).TotalSeconds <= 2)
{