From 1af7b0398731ea3f6d134beb363b648c3844b6e3 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 11 Sep 2022 15:28:37 +0200 Subject: [PATCH] Bump JDA & close Inpustream --- build.gradle | 2 +- .../bungeecore/bot/listeners/PrivateMessageListener.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index dd9ed88..789fc21 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ dependencies { compileOnly 'de.steamwar:waterfall:RELEASE' compileOnly 'de.steamwar:persistentbungeecore:RELEASE' - implementation("net.dv8tion:JDA:4.3.0_299") { + implementation("net.dv8tion:JDA:4.4.0_352") { exclude module: 'opus-java' } diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java index 8f55731..c458e07 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java @@ -25,6 +25,9 @@ import de.steamwar.bungeecore.sql.SteamwarUser; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; + public class PrivateMessageListener extends BasicDiscordListener { @Override @@ -63,7 +66,9 @@ public class PrivateMessageListener extends BasicDiscordListener { } try { - node.saveFromStream(attachment.retrieveInputStream().get(), newFormat); + InputStream in = attachment.retrieveInputStream().get(); + node.saveFromStream(in, newFormat); + in.close(); event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue(); } catch (Exception e) { event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();