From ecd688310fb90fe7da005ff3644f1198fcb4185d Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 27 Jun 2024 13:33:38 +0100 Subject: [PATCH] add fetch time for scoresaber me and user command --- .../scoresaber/command/scoresaber/ScoreSaberCommand.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java index 5641379..52c2fe0 100644 --- a/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java +++ b/src/main/java/cc/fascinated/bat/features/scoresaber/command/scoresaber/ScoreSaberCommand.java @@ -48,9 +48,9 @@ public class ScoreSaberCommand extends BatCommand { /** * Builds the profile embed for the ScoreSaber profile * - * @param user The user to build the profile embed for + * @param user The user to build the profile embed for * @param scoreSaberService The ScoreSaber service - * @param interaction The interaction + * @param interaction The interaction */ public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) { UserScoreSaberProfile profile = user.getProfile(UserScoreSaberProfile.class); @@ -67,6 +67,7 @@ public class ScoreSaberCommand extends BatCommand { } try { + long before = System.currentTimeMillis(); ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId()); if (account == null) { if (!isSelf) { @@ -81,6 +82,7 @@ public class ScoreSaberCommand extends BatCommand { return; } + long fetchTime = System.currentTimeMillis() - before; interaction.replyEmbeds(new EmbedBuilder() .setAuthor(account.getName() + "'s Profile", "https://scoresaber.com/u/%s".formatted(account.getId()), "https://cdn.scoresaber.com/avatars/%s.jpg".formatted(account.getId())) @@ -89,8 +91,9 @@ public class ScoreSaberCommand extends BatCommand { .addField("Rank", "#" + NumberUtils.formatNumberCommas(account.getRank()), true) .addField("Country Rank", "#" + NumberUtils.formatNumberCommas(account.getCountryRank()), true) .addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true) - .addField("Joined", "".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli()/1000), true) + .addField("Joined", "".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli() / 1000), true) .setTimestamp(LocalDateTime.now()) + .setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", null) .setColor(Colors.DEFAULT) .build()).queue(); } catch (RateLimitException ex) {