From 4414eea5133a1c4e01f34feba0a57b11ea652aac Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Sun, 27 Nov 2022 14:29:36 -0500 Subject: [PATCH] Close discord webhook clients on shutdown (#5165) --- .../java/net/essentialsx/discord/JDADiscordService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java index 129b64985..a1030442c 100644 --- a/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java +++ b/EssentialsDiscord/src/main/java/net/essentialsx/discord/JDADiscordService.java @@ -333,7 +333,7 @@ public class JDADiscordService implements DiscordService, IEssentialsModule { if (current != null) { current.close(); } - channelIdToWebhook.remove(channel.getId()); + channelIdToWebhook.remove(channel.getId()).close(); continue; } typeToChannelId.put(type, channel.getId()); @@ -430,6 +430,10 @@ public class JDADiscordService implements DiscordService, IEssentialsModule { shutdownConsoleRelay(true); + for (WebhookClient webhook : channelIdToWebhook.values()) { + webhook.close(); + } + // Unregister leftover jda listeners for (Object obj : jda.getRegisteredListeners()) { if (!(obj instanceof EventListener)) { // Yeah bro I wish I knew too :/