Open
Description
General Troubleshooting
- I have checked for similar issues on the Issue-tracker.
- I have checked for PRs that might already address this issue.
Version of JDA
5.3.2
Expected Behaviour
Hi guys.
Found a wrong expected type in AuditLogKey (MEMBER_ROLES_ADD and MEMBER_ROLES_REMOVE) in jda docs.
So according to the docs both keys MEMBER_ROLES_ADD and MEMBER_ROLES_REMOVE are supposed to give us List with role IDs. However we actually get List<Map<String, String>>, where the key is role's name and the value is it's ID.
Code Example for Reproduction Steps
AuditLogChange rolesAdded = auditLogEntry.getChangeByKey(MEMBER_ROLES_ADD);
Set<Long> addedRolesIds = extractRoleIds(rolesAddedChange);
private Set<Long> extractRoleIds(AuditLogChange change) {
if (change == null || !(change.getNewValue() instanceof List<?> newValue)) {
return Collections.emptySet();
}
return newValue.stream()
.filter(Map.class::isInstance) // Works just fine
.map(Map.class::cast)
.map(map -> map.get("id"))
.filter(Objects::nonNull)
.map(String.class::cast)
.map(Long::parseLong)
.collect(Collectors.toUnmodifiableSet());
}
Code for JDABuilder or DefaultShardManagerBuilder used
default
Exception or Error