Made delivered reactions more reliable
This commit is contained in:
parent
7e5ab8cbbd
commit
6cdac8696d
1 changed files with 11 additions and 2 deletions
|
@ -110,7 +110,7 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
"Sorry, you need to be online on the server and have your accounts connected, you can only access these commands:\n"
|
"Sorry, you need to be online on the server and have your accounts connected, you can only access these commands:\n"
|
||||||
+ Arrays.stream(UnconnectedCmds).map(uc -> "/" + uc)
|
+ Arrays.stream(UnconnectedCmds).map(uc -> "/" + uc)
|
||||||
.collect(Collectors.joining(", "))
|
.collect(Collectors.joining(", "))
|
||||||
+ "\nTo connect your accounts, use @ChromaBot connect here or in "
|
+ "\nTo connect your accounts, use @ChromaBot connect in "
|
||||||
+ DiscordPlugin.botchannel.mention());
|
+ DiscordPlugin.botchannel.mention());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,6 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
|
dmessage + (event.getMessage().getAttachments().size() > 0 ? "\n" + event.getMessage()
|
||||||
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
|
.getAttachments().stream().map(a -> a.getUrl()).collect(Collectors.joining("\n"))
|
||||||
: ""));
|
: ""));
|
||||||
event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
|
|
||||||
event.getMessage().getChannel().getMessages().stream().forEach(m -> {
|
event.getMessage().getChannel().getMessages().stream().forEach(m -> {
|
||||||
try {
|
try {
|
||||||
final IReaction reaction = m.getReactionByName(DiscordPlugin.DELIVERED_REACTION);
|
final IReaction reaction = m.getReactionByName(DiscordPlugin.DELIVERED_REACTION);
|
||||||
|
@ -139,6 +138,16 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
TBMCCoreAPI.SendException("An error occured while removing reactions from chat!", e);
|
TBMCCoreAPI.SendException("An error occured while removing reactions from chat!", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
while (true)
|
||||||
|
try {
|
||||||
|
event.getMessage().addReaction(DiscordPlugin.DELIVERED_REACTION);
|
||||||
|
break;
|
||||||
|
} catch (RateLimitException e) {
|
||||||
|
if (e.getRetryDelay() > 0)
|
||||||
|
Thread.sleep(e.getRetryDelay());
|
||||||
|
else
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TBMCCoreAPI.SendException("An error occured while handling message \"" + dmessage + "\"!", e);
|
TBMCCoreAPI.SendException("An error occured while handling message \"" + dmessage + "\"!", e);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue