Skip to content

Commit

Permalink
Add support for reverse audit-log iteration (#2370)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment committed Jan 11, 2023
1 parent e20f53a commit 83ae997
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -84,7 +84,7 @@ public Guild getGuild()
@Override
public EnumSet<PaginationOrder> getSupportedOrders()
{
return EnumSet.of(PaginationOrder.BACKWARD);
return EnumSet.of(PaginationOrder.BACKWARD, PaginationOrder.FORWARD);
}

@Override
Expand Down Expand Up @@ -135,17 +135,21 @@ protected void handleSuccess(Response response, Request<List<AuditLogEntry>> req
DataObject webhook = webhookMap.get(entry.getLong("target_id", 0));
AuditLogEntry result = builder.createAuditLogEntry((GuildImpl) guild, entry, user, webhook);
list.add(result);
if (this.useCache)
this.cached.add(result);
this.last = result;
this.lastKey = last.getIdLong();
}
catch (ParsingException | NullPointerException e)
{
LOG.warn("Encountered exception in AuditLogPagination", e);
}
}

if (!list.isEmpty())
{
if (this.useCache)
this.cached.addAll(list);
this.last = list.get(list.size() - 1);
this.lastKey = last.getIdLong();
}

request.onSuccess(list);
}

Expand Down

0 comments on commit 83ae997

Please sign in to comment.