forked from TeamInklings/Octobot
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:
parent
e35db12ab3
commit
926dc0f1b7
1 changed files with 11 additions and 5 deletions
|
@ -69,11 +69,17 @@ public static class EventHandler {
|
|||
|
||||
await Task.Delay(500);
|
||||
|
||||
var auditLogEntry = (await guild.GetAuditLogsAsync(1).FlattenAsync()).First();
|
||||
var auditLogEnumerator
|
||||
= (await guild.GetAuditLogsAsync(1, actionType: ActionType.MessageDeleted).FlattenAsync()).GetEnumerator();
|
||||
if (auditLogEnumerator.MoveNext()) {
|
||||
var auditLogEntry = auditLogEnumerator.Current!;
|
||||
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(
|
||||
string.Format(
|
||||
|
|
Reference in a new issue