Merge branch 'master' into dev

This commit is contained in:
Norbi Peti 2019-10-30 19:41:29 +01:00 committed by GitHub
commit 0e4a9ff7e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -130,6 +130,7 @@ public class DiscordPlugin extends ButtonPlugin {
.take(size) // Take only the first `size` GuildCreateEvent(s) to be received .take(size) // Take only the first `size` GuildCreateEvent(s) to be received
.collectList()) // Take all received GuildCreateEvents and make it a List .collectList()) // Take all received GuildCreateEvents and make it a List
.subscribe(this::handleReady); /* All guilds have been received, client is fully connected */ .subscribe(this::handleReady); /* All guilds have been received, client is fully connected */
//dc.getEventDispatcher().on(DisconnectEvent.class);
dc.login().subscribe(); dc.login().subscribe();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -141,8 +142,8 @@ public class DiscordPlugin extends ButtonPlugin {
private void handleReady(List<GuildCreateEvent> event) { private void handleReady(List<GuildCreateEvent> event) {
try { try {
if(!SafeMode) { if (mainServer != null) { //This is not the first ready event
getLogger().info("Ready again, already enabled."); //TODO: It should probably handle disconnections getLogger().info("Ready event already handled"); //TODO: It should probably handle disconnections
return; return;
} }
mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards mainServer = mainServer().get().orElse(null); //Shouldn't change afterwards
@ -272,6 +273,7 @@ public class DiscordPlugin extends ButtonPlugin {
//dc.updatePresence(Presence.idle(Activity.playing("logging out"))).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();
mainServer = null; //Allow ReadyEvent again
//Configs are emptied so channels and servers are fetched again //Configs are emptied so channels and servers are fetched again
} catch (Exception e) { } catch (Exception e) {
TBMCCoreAPI.SendException("An error occured while disabling DiscordPlugin!", e); TBMCCoreAPI.SendException("An error occured while disabling DiscordPlugin!", e);