Hopefully fix discord being killed incorrectly

This commit is contained in:
Business Goose 2022-03-30 00:03:22 +01:00
parent d033b96376
commit 27f5019982
No known key found for this signature in database
GPG key ID: 77DCA801362E9645

View file

@ -193,13 +193,16 @@ public class DiscordBridge {
}
CountDownLatch shutdownWaiter = new CountDownLatch(1);
DISCORD_API.addLostConnectionListener(lostConnectionEvent -> shutdownWaiter.countDown());
DISCORD_API.disconnect();
Thread t = new Thread(() -> {
DISCORD_API.addLostConnectionListener(lostConnectionEvent -> shutdownWaiter.countDown());
DISCORD_API.disconnect();
try {
shutdownWaiter.await(30, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
try {
shutdownWaiter.await(30, TimeUnit.SECONDS);
} catch (InterruptedException ignored) {
}
});
t.start();
}
}