use of sx.blah.discord.api.internal.json.objects.audit.AuditLogObject in project Discord4J by Discord4J.
the class Guild method getAuditLog.
private AuditLog getAuditLog(IUser user, ActionType actionType, long before) {
PermissionUtils.requirePermissions(this, client.getOurUser(), Permissions.VIEW_AUDIT_LOG);
List<AuditLog> retrieved = new ArrayList<>();
AuditLogEntryObject[] chunk;
do {
String query = "?limit=100&before=" + before;
if (user != null)
query += "&user_id=" + Long.toUnsignedString(user.getLongID());
if (actionType != null)
query += "&action_type=" + actionType.getRaw();
AuditLogObject auditLog = ((DiscordClientImpl) client).REQUESTS.GET.makeRequest(DiscordEndpoints.GUILDS + getStringID() + "/audit-logs" + query, AuditLogObject.class);
chunk = auditLog.audit_log_entries;
if (chunk.length == 0)
break;
retrieved.add(DiscordUtils.getAuditLogFromJSON(this, auditLog));
before = Long.parseLong(auditLog.audit_log_entries[auditLog.audit_log_entries.length - 1].id);
} while (chunk.length == 100);
return new AuditLog(retrieved.stream().map(AuditLog::getEntries).flatMap(Collection::stream).collect(LongMapCollector.toLongMap()));
}
Aggregations