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.EmbedUtils;
|
||||
import cc.fascinated.bat.common.NumberUtils;
|
||||
import cc.fascinated.bat.exception.RateLimitException;
|
||||
import cc.fascinated.bat.features.scoresaber.profile.UserScoreSaberProfile;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
@ -65,7 +66,7 @@ public class ScoreSaberCommand extends BatCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// todo: handle rate limits
|
||||
try {
|
||||
ScoreSaberAccountToken account = scoreSaberService.getAccount(profile.getSteamId());
|
||||
if (account == null) {
|
||||
if (!isSelf) {
|
||||
@ -92,5 +93,10 @@ public class ScoreSaberCommand extends BatCommand {
|
||||
.setTimestamp(LocalDateTime.now())
|
||||
.setColor(Colors.DEFAULT)
|
||||
.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