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 97fcfb2..0dfe47e 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 @@ -67,6 +67,7 @@ public class ScoreSaberCommand extends BatCommand { try { long before = System.currentTimeMillis(); + boolean cached = scoreSaberService.isCached(profile.getAccountId()); ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getAccountId()); if (account == null) { if (!isSelf) { @@ -96,7 +97,7 @@ public class ScoreSaberCommand extends BatCommand { .addField("PP", NumberFormatter.formatCommas(account.getPp()), true) .addField("Joined", "".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().getEpochSecond()), true) .setTimestamp(LocalDateTime.now()) - .setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", "https://flagcdn.com/h120/%s.png".formatted(account.getCountry().toLowerCase())) + .setFooter(!cached ? "Fetched in %sms".formatted(fetchTime) : "Cached", "https://flagcdn.com/h120/%s.png".formatted(account.getCountry().toLowerCase())) .setColor(Colors.DEFAULT) .build()).queue(); } catch (RateLimitException ex) { diff --git a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java index 1dd8d4f..c9b2b92 100644 --- a/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java +++ b/src/main/java/cc/fascinated/bat/service/ScoreSaberService.java @@ -46,6 +46,16 @@ public class ScoreSaberService extends TextWebSocketHandler { connectWebSocket(); } + /** + * Checks if the account is cached. + * + * @param id The id of the account. + * @return If the account is cached. + */ + public boolean isCached(String id) { + return cachedAccounts.containsKey(id); + } + /** * Gets the account from the ScoreSaber API. *