Make sure the audit log enumerable is not empty when determining message deleter

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-04-27 22:53:28 +05:00
parent e35db12ab3
commit 926dc0f1b7
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -69,11 +69,17 @@ public static class EventHandler {
await Task.Delay(500); await Task.Delay(500);
var auditLogEntry = (await guild.GetAuditLogsAsync(1).FlattenAsync()).First(); var auditLogEnumerator
if (auditLogEntry.CreatedAt >= DateTimeOffset.UtcNow.Subtract(TimeSpan.FromSeconds(1)) = (await guild.GetAuditLogsAsync(1, actionType: ActionType.MessageDeleted).FlattenAsync()).GetEnumerator();
&& auditLogEntry.Data is MessageDeleteAuditLogData data if (auditLogEnumerator.MoveNext()) {
&& msg.Author.Id == data.Target.Id) var auditLogEntry = auditLogEnumerator.Current!;
mention = auditLogEntry.User.Mention; if (auditLogEntry.CreatedAt >= DateTimeOffset.UtcNow.Subtract(TimeSpan.FromSeconds(1))
&& auditLogEntry.Data is MessageDeleteAuditLogData data
&& msg.Author.Id == data.Target.Id)
mention = auditLogEntry.User.Mention;
}
auditLogEnumerator.Dispose();
await Utils.SendFeedbackAsync( await Utils.SendFeedbackAsync(
string.Format( string.Format(