fix cached footer

This commit is contained in:
Lee 2024-07-04 15:44:05 +01:00
parent 9a5609f40e
commit c78033f409
2 changed files with 12 additions and 1 deletions

@ -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", "<t:%s>".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) {

@ -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.
*