add fetch time for scoresaber me and user command
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 39s
This commit is contained in:
parent
001ece7899
commit
ecd688310f
@ -48,9 +48,9 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
/**
|
/**
|
||||||
* Builds the profile embed for the ScoreSaber profile
|
* 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 scoreSaberService The ScoreSaber service
|
||||||
* @param interaction The interaction
|
* @param interaction The interaction
|
||||||
*/
|
*/
|
||||||
public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) {
|
public static void sendProfileEmbed(boolean isSelf, BatUser user, ScoreSaberService scoreSaberService, SlashCommandInteraction interaction) {
|
||||||
UserScoreSaberProfile profile = user.getProfile(UserScoreSaberProfile.class);
|
UserScoreSaberProfile profile = user.getProfile(UserScoreSaberProfile.class);
|
||||||
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user