Fix presence updater index out of bounds, minimum updater rate

This commit is contained in:
Vankka 2024-11-17 21:36:05 +02:00
parent e62302e024
commit a948df6070
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB

View File

@ -122,13 +122,13 @@ public class PresenceUpdaterModule extends AbstractModule<DiscordSRV> {
return;
}
Duration duration = Duration.ofSeconds(config.updaterRateInSeconds);
Duration duration = Duration.ofSeconds(Math.max(config.updaterRateInSeconds, 30));
future = discordSRV.scheduler().runAtFixedRate(() -> {
int index = currentIndex.getAndUpdate(value -> {
if (count <= value) {
return 0;
if (count > ++value) {
return value;
}
return value + 1;
return 0;
});
setPresence(presences.get(index));
}, alreadyScheduled ? duration : Duration.ZERO, duration);