Skip to content

Commit

Permalink
refac(service): Added support for codec design in XP api (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seb committed Apr 20, 2022
1 parent e9a4ad0 commit c7baa97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ private void sendLevelCard(CommandContext context, Member member, long serverID)

byte[] xpCard = xpService.getExperienceCard(member.getUser().getAvatarUrl(),
userXP.getCurrentExperience(), xpService.xpNeededForLevel(userXP.getNextLevel()),
userXP.getCurrentLevel(), 1, member.getUser().getName() + "#" + member.getUser().getDiscriminator(),
"#FF0000", "#2E2E2E");
userXP.getCurrentLevel(), 1, member.getUser().getName(), member.getUser().getDiscriminator(), "#F24548",
"#3B43D5", "#2F3136");
context.replyWithFile(xpCard, "xpcard.png");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ public class ExperienceService {
private static final int EXPERIENCE_DELAY = 0; //Delay between incrementing XP in seconds

public byte[] getExperienceCard(String avatarURL, long xpAchieved, long xpNeeded,
long level, long rank, String username, String barColour, String background) {
long level, long rank, String username, String discriminator, String barFromColour,
String barToColour, String background) {
try {
String cardURL = config.getExperienceCardApiURL() + "xpcard/?avatar_url=" + avatarURL +
"&xp=" + xpAchieved + "&xp_needed=" + xpNeeded + "&level=" + level + "&rank=" + rank
+ "&username=" + URLEncoder.encode(username, StandardCharsets.UTF_8.toString())
+ "&bar_colour=" + URLEncoder.encode(barColour, StandardCharsets.UTF_8.toString())
+ "&discriminator=" + URLEncoder.encode(discriminator, StandardCharsets.UTF_8.toString())
+ "&bar_colour_from=" + URLEncoder.encode(barFromColour, StandardCharsets.UTF_8.toString())
+ "&bar_colour_to=" + URLEncoder.encode(barToColour, StandardCharsets.UTF_8.toString())
+ "&bg_colour=" + URLEncoder.encode(background, StandardCharsets.UTF_8.toString());
URL url = new URL(cardURL);
//Remove the data:image/png;base64 part
Expand Down

0 comments on commit c7baa97

Please sign in to comment.