use of net.dv8tion.jda.api.audit.ActionType in project JDA by DV8FromTheWorld.
the class EntityBuilder method createAuditLogEntry.
public AuditLogEntry createAuditLogEntry(GuildImpl guild, DataObject entryJson, DataObject userJson, DataObject webhookJson) {
final long targetId = entryJson.getLong("target_id", 0);
final long id = entryJson.getLong("id");
final int typeKey = entryJson.getInt("action_type");
final DataArray changes = entryJson.isNull("changes") ? null : entryJson.getArray("changes");
final DataObject options = entryJson.isNull("options") ? null : entryJson.getObject("options");
final String reason = entryJson.getString("reason", null);
final UserImpl user = userJson == null ? null : createUser(userJson);
final WebhookImpl webhook = webhookJson == null ? null : createWebhook(webhookJson);
final Set<AuditLogChange> changesList;
final ActionType type = ActionType.from(typeKey);
if (changes != null) {
changesList = new HashSet<>(changes.length());
for (int i = 0; i < changes.length(); i++) {
final DataObject object = changes.getObject(i);
AuditLogChange change = createAuditLogChange(object);
changesList.add(change);
}
} else {
changesList = Collections.emptySet();
}
CaseInsensitiveMap<String, AuditLogChange> changeMap = new CaseInsensitiveMap<>(changeToMap(changesList));
CaseInsensitiveMap<String, Object> optionMap = options != null ? new CaseInsensitiveMap<>(options.toMap()) : null;
return new AuditLogEntry(type, typeKey, id, targetId, guild, user, webhook, reason, changeMap, optionMap);
}
Aggregations