Search code examples
javadiscord4j

Discord4j getting a username from id


is there any way in Discord4j to get someone's username using their id? The only way I have found so far is using UserData.builder().id("id").username("username").discriminator("0000").build();, but this requires you to manualy specify a username. Is there any other way?


Solution

  • You should not be building D4J DataX classes yourself. DataX classes are the raw JSON mappings of what Discord sends and are mapped using Jackson.

    To get a user from ID: GatewayDiscordClient#getUserFromId(userId)