forked from Fascinated/Bat
fix cached footer
This commit is contained in:
parent
9a5609f40e
commit
c78033f409
@ -67,6 +67,7 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
long before = System.currentTimeMillis();
|
long before = System.currentTimeMillis();
|
||||||
|
boolean cached = scoreSaberService.isCached(profile.getAccountId());
|
||||||
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getAccountId());
|
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getAccountId());
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
@ -96,7 +97,7 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
.addField("PP", NumberFormatter.formatCommas(account.getPp()), true)
|
.addField("PP", NumberFormatter.formatCommas(account.getPp()), true)
|
||||||
.addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().getEpochSecond()), true)
|
.addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().getEpochSecond()), true)
|
||||||
.setTimestamp(LocalDateTime.now())
|
.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)
|
.setColor(Colors.DEFAULT)
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
} catch (RateLimitException ex) {
|
} catch (RateLimitException ex) {
|
||||||
|
@ -46,6 +46,16 @@ public class ScoreSaberService extends TextWebSocketHandler {
|
|||||||
connectWebSocket();
|
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.
|
* Gets the account from the ScoreSaber API.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user