Added ratelimit handling for reaction remove

This commit is contained in:
Norbi Peti 2016-12-21 22:58:23 +01:00
parent 51e96b982a
commit 2053b7f508

View file

@ -104,8 +104,16 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
event.getMessage().getChannel().getMessages().stream().forEach(m -> {
try {
final IReaction reaction = m.getReactionByName(DELIVERED_REACTION);
if (reaction != null)
m.removeReaction(reaction);
if (reaction != null) {
while (true)
try {
m.removeReaction(reaction);
Thread.sleep(100);
break;
} catch (RateLimitException e) {
Thread.sleep(e.getRetryDelay());
}
}
} catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while removing reactions from chat!", e);
}