forked from Fascinated/Bat
add rate limit check for scoresaber api
This commit is contained in:
parent
b50e30ffc5
commit
4a7e7de6a2
@ -5,6 +5,7 @@ import cc.fascinated.bat.common.Colors;
|
|||||||
import cc.fascinated.bat.common.DateUtils;
|
import cc.fascinated.bat.common.DateUtils;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.common.NumberUtils;
|
import cc.fascinated.bat.common.NumberUtils;
|
||||||
|
import cc.fascinated.bat.exception.RateLimitException;
|
||||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -65,7 +66,7 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: handle rate limits
|
try {
|
||||||
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId());
|
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId());
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
@ -92,5 +93,10 @@ public class ScoreSaberCommand extends BatCommand {
|
|||||||
.setTimestamp(LocalDateTime.now())
|
.setTimestamp(LocalDateTime.now())
|
||||||
.setColor(Colors.DEFAULT)
|
.setColor(Colors.DEFAULT)
|
||||||
.build()).queue();
|
.build()).queue();
|
||||||
|
} catch (RateLimitException ex) {
|
||||||
|
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
||||||
|
.setDescription("The ScoreSaber API is currently rate our limiting requests, please try again later")
|
||||||
|
.build()).queue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user