public static Icon getAvatar ( DiscordApi api , String avatarHash , String discriminator , long userId ) { StringBuilder url = new StringBuilder ( "https://cdn.discordapp.com/" ) ; if ( avatarHash == null ) { url . append ( "embed/avatars/" ) . append ( Integer . parseInt ( discriminator ) % 5 ) . append ( ".png" ) ; } else { url . append ( "avatars/" ) . append ( userId ) . append ( ' ' ) . append ( avatarHash ) . append ( avatarHash . startsWith ( "a_" ) ? ".gif" : ".png" ) ; } try { return new IconImpl ( api , new URL ( url . toString ( ) ) ) ; } catch ( MalformedURLException e ) { logger . warn ( "Seems like the url of the avatar is malformed! Please contact the developer!" , e ) ; return null ; } }
Gets the avatar for the given details .