add fetch time for scoresaber me and user command
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s

This commit is contained in:
Lee 2024-06-27 13:33:38 +01:00
parent 001ece7899
commit ecd688310f

@ -67,6 +67,7 @@ public class ScoreSaberCommand extends BatCommand {
} }
try { try {
long before = System.currentTimeMillis();
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId()); ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId());
if (account == null) { if (account == null) {
if (!isSelf) { if (!isSelf) {
@ -81,6 +82,7 @@ public class ScoreSaberCommand extends BatCommand {
return; return;
} }
long fetchTime = System.currentTimeMillis() - before;
interaction.replyEmbeds(new EmbedBuilder() interaction.replyEmbeds(new EmbedBuilder()
.setAuthor(account.getName() + "'s Profile", "https://scoresaber.com/u/%s".formatted(account.getId()), .setAuthor(account.getName() + "'s Profile", "https://scoresaber.com/u/%s".formatted(account.getId()),
"https://cdn.scoresaber.com/avatars/%s.jpg".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("Rank", "#" + NumberUtils.formatNumberCommas(account.getRank()), true)
.addField("Country Rank", "#" + NumberUtils.formatNumberCommas(account.getCountryRank()), true) .addField("Country Rank", "#" + NumberUtils.formatNumberCommas(account.getCountryRank()), true)
.addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true) .addField("PP", NumberUtils.formatNumberCommas(account.getPp()), true)
.addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli()/1000), true) .addField("Joined", "<t:%s>".formatted(DateUtils.getDateFromString(account.getFirstSeen()).toInstant().toEpochMilli() / 1000), true)
.setTimestamp(LocalDateTime.now()) .setTimestamp(LocalDateTime.now())
.setFooter(fetchTime > 3 ? "Fetched in %sms".formatted(fetchTime) : "Cached", null)
.setColor(Colors.DEFAULT) .setColor(Colors.DEFAULT)
.build()).queue(); .build()).queue();
} catch (RateLimitException ex) { } catch (RateLimitException ex) {