Hopefully fixed the issue of multiple ready events

#107
This commit is contained in:
Norbi Peti 2019-09-11 15:30:07 +02:00 committed by GitHub
parent ea0ef88068
commit acd45ce4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -141,6 +141,10 @@ public class DiscordPlugin extends ButtonPlugin {
private void handleReady(List<GuildCreateEvent> event) { private void handleReady(List<GuildCreateEvent> event) {
try { try {
if(!SafeMode) {
getLogger().info("Ready again, already enabled."); //TODO: It should probably handle disconnections
return;
}
mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards
getCommand2MC().registerCommand(new DiscordMCCommand()); //Register so that the reset command works getCommand2MC().registerCommand(new DiscordMCCommand()); //Register so that the reset command works
if (mainServer == null) { if (mainServer == null) {
@ -264,8 +268,8 @@ public class DiscordPlugin extends ButtonPlugin {
try { try {
SafeMode = true; // Stop interacting with Discord SafeMode = true; // Stop interacting with Discord
ChromaBot.delete(); ChromaBot.delete();
timings.printElapsed("Updating presence..."); //timings.printElapsed("Updating presence...");
dc.updatePresence(Presence.idle(Activity.playing("Chromacraft"))).block(); //No longer using the same account for testing //dc.updatePresence(Presence.idle(Activity.playing("logging out"))).block(); //No longer using the same account for testing
timings.printElapsed("Logging out..."); timings.printElapsed("Logging out...");
dc.logout().block(); dc.logout().block();
//Configs are emptied so channels and servers are fetched again //Configs are emptied so channels and servers are fetched again