public void addMember ( JsonNode member ) { User user = api . getOrCreateUser ( member . get ( "user" ) ) ; members . put ( user . getId ( ) , user ) ; if ( member . hasNonNull ( "nick" ) ) { nicknames . put ( user . getId ( ) , member . get ( "nick" ) . asText ( ) ) ; } if ( member . hasNonNull ( "mute" ) ) { setMuted ( user . getId ( ) , member . get ( "mute" ) . asBoolean ( ) ) ; } if ( member . hasNonNull ( "deaf" ) ) { setDeafened ( user . getId ( ) , member . get ( "deaf" ) . asBoolean ( ) ) ; } for ( JsonNode roleIds : member . get ( "roles" ) ) { long roleId = Long . parseLong ( roleIds . asText ( ) ) ; getRoleById ( roleId ) . map ( role -> ( ( RoleImpl ) role ) ) . ifPresent ( role -> role . addUserToCache ( user ) ) ; } joinedAtTimestamps . put ( user . getId ( ) , OffsetDateTime . parse ( member . get ( "joined_at" ) . asText ( ) ) . toInstant ( ) ) ; synchronized ( readyConsumers ) { if ( ! ready && members . size ( ) == getMemberCount ( ) ) { ready = true ; readyConsumers . forEach ( consumer -> consumer . accept ( this ) ) ; readyConsumers . clear ( ) ; } } }
Adds a member to the server .