Skip to content

Discord: Add PAPI support to avatar-url #6189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ public static boolean matchesRole(Role role, String roleDefinition) {
}

public static String getAvatarUrl(final JDADiscordService jda, final Player player) {
return jda.getSettings().getAvatarURL().replace("{uuid}", player.getUniqueId().toString()).replace("{name}", player.getName());
final String format = jda.getSettings().getAvatarURL();
final String filled;
if (jda.getPlugin().isPAPI() && format != null) {
filled = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, format);
} else {
filled = format;
}
return filled.replace("{uuid}", player.getUniqueId().toString()).replace("{name}", player.getName());
}

public static void dispatchDiscordMessage(final JDADiscordService jda, final MessageType messageType, final String message, final boolean allowPing, final String avatarUrl, final String name, final UUID uuid) {
Expand Down
3 changes: 2 additions & 1 deletion EssentialsDiscord/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ discord-url: "https://discord.gg/invite-code"

# Defined text channels
# =====================
#
#
# Channels defined here can be used for two different purposes:
#
# Firstly, channels defined here can be used to give players permission to see messages from said channel.
Expand Down Expand Up @@ -163,6 +163,7 @@ show-avatar: false
# Any URL in here should only return a proper JPEG/PNG image and nothing else.
# To include the UUID of the player in this URL, use "{uuid}".
# To include the name of the player in this URL, use "{name}".
# ... PlaceholderAPI placeholders are also supported here too!
avatar-url: "https://crafthead.net/helm/{uuid}"

# Whether or not fake join and leave messages should be sent to Discord when a player toggles vanish in Minecraft.
Expand Down
Loading