DiscordSRV

DiscordSRV

86.8k Downloads

API getAvatarUrl not working in offline servers

AlessioDP opened this issue ยท 4 comments

commented

Hello, I am implementing DiscordSRV:2.12.3 and when I use getAvatarUrl there is an error in console and returns the default MC avatar.

This is the code that I am using:

System.out.println("Name: " + player.getName() + " | UUID: " + player.getPlayerUUID().toString());
mf.setAuthorImageUrl(DiscordSRV.getAvatarUrl(player.getName(), player.getPlayerUUID())); // MessageFormat mf;

I receive this error in console:

>: Name: AlessioDP | UUID: 0bd828fb-0337-3389-af9d-204fe4f4f02e
>: [DiscordSRV] Your AvatarUrl does not contain the {username} placeholder even though this server is using offline UUIDs.
>: [DiscordSRV] You should set your AvatarUrl to https://minotar.net/helm/{username}/{size}.png#{texture} to get avatars to work.
commented

The UUID you're supplying, as the error says, is an offline UUID. You need to set your AvatarUrl to what the error says in order to fetch avatars properly because offline UUIDs don't have textures associated with them.

commented

I thought that was done by DiscordSRV itself.

Is not possible for DiscordSRV understands that then use player.getName() instead of the UUID given?
If I understand correctly, I should handle the offline thing by myself and insert that URL instead of using DiscordSRV.getAvatarUrl(...)?

commented

I thought that was done by DiscordSRV itself.

There are legitimate reasons to not have the {username} placeholder when using offline UUIDs. DiscordSRV changing that itself would be problematic for those reasons.

commented

Okay I understand now. I thought it was a problem related to API but its a configuration of DiscordSRV itself.

Sorry for the issue, have a good day :)