From a9f8bcb71b8bd49115e88e983ce1a53c695affe5 Mon Sep 17 00:00:00 2001 From: Xirado Date: Sat, 5 Feb 2022 15:31:21 +0100 Subject: [PATCH 1/4] override MessageAction#addFile(byte[], String, AttachmentOption...) overload in MessageActionImpl --- .../jda/api/requests/restaction/MessageAction.java | 9 ++------- .../requests/restaction/MessageActionImpl.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java index d3594cffbe..3672dda1cb 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java @@ -17,6 +17,7 @@ package net.dv8tion.jda.api.requests.restaction; import net.dv8tion.jda.api.MessageBuilder; +import net.dv8tion.jda.api.entities.GuildChannel; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.MessageChannel; import net.dv8tion.jda.api.entities.MessageEmbed; @@ -597,13 +598,7 @@ default MessageAction appendFormat(@Nonnull final String format, final Object... */ @Nonnull @CheckReturnValue - default MessageAction addFile(@Nonnull final byte[] data, @Nonnull final String name, @Nonnull AttachmentOption... options) - { - Checks.notNull(data, "Data"); - final long maxSize = getJDA().getSelfUser().getAllowedFileSize(); - Checks.check(data.length <= maxSize, "File may not exceed the maximum file length of %d bytes!", maxSize); - return addFile(new ByteArrayInputStream(data), name, options); - } + MessageAction addFile(@Nonnull final byte[] data, @Nonnull final String name, @Nonnull AttachmentOption... options); /** * Adds the provided {@link java.io.File File} as file data. diff --git a/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java b/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java index cac3239313..1f0daba267 100644 --- a/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java @@ -38,6 +38,7 @@ import net.dv8tion.jda.internal.utils.IOUtil; import okhttp3.MultipartBody; import okhttp3.RequestBody; +import org.jetbrains.annotations.NotNull; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; @@ -316,6 +317,16 @@ public MessageActionImpl addFile(@Nonnull final File file, @Nonnull String name, } } + @NotNull + @Override + public MessageAction addFile(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) + { + Checks.notNull(data, "Data"); + final long maxSize = getMaxFileSize(); + Checks.check(data.length <= maxSize, "File may not exceed the maximum file length of %d bytes!", maxSize); + return addFile(new ByteArrayInputStream(data), name, options); + } + @Nonnull @Override @CheckReturnValue From 152e52160d6e53bce0f403fc60c8ec23bfd04e92 Mon Sep 17 00:00:00 2001 From: Xirado Date: Sat, 5 Feb 2022 15:33:19 +0100 Subject: [PATCH 2/4] Don't use jetbrains annotation --- .../jda/internal/requests/restaction/MessageActionImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java b/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java index 1f0daba267..6cf40c8d38 100644 --- a/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/requests/restaction/MessageActionImpl.java @@ -38,7 +38,6 @@ import net.dv8tion.jda.internal.utils.IOUtil; import okhttp3.MultipartBody; import okhttp3.RequestBody; -import org.jetbrains.annotations.NotNull; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; @@ -317,7 +316,7 @@ public MessageActionImpl addFile(@Nonnull final File file, @Nonnull String name, } } - @NotNull + @Nonnull @Override public MessageAction addFile(@Nonnull byte[] data, @Nonnull String name, @Nonnull AttachmentOption... options) { From 92e9e53ca3676211be2e065a2786db6096eef8b9 Mon Sep 17 00:00:00 2001 From: Xirado Date: Sun, 6 Feb 2022 16:38:00 +0100 Subject: [PATCH 3/4] Removed unnecessary import --- .../net/dv8tion/jda/api/requests/restaction/MessageAction.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java index 3672dda1cb..64b5e0ee10 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java @@ -17,7 +17,6 @@ package net.dv8tion.jda.api.requests.restaction; import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.GuildChannel; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.MessageChannel; import net.dv8tion.jda.api.entities.MessageEmbed; From 51f8f3b4854daf70416f2e793ce23d5eb30a6e68 Mon Sep 17 00:00:00 2001 From: Xirado Date: Sun, 6 Feb 2022 16:38:19 +0100 Subject: [PATCH 4/4] Removed another import --- .../net/dv8tion/jda/api/requests/restaction/MessageAction.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java index 64b5e0ee10..5d928c3966 100644 --- a/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java +++ b/src/main/java/net/dv8tion/jda/api/requests/restaction/MessageAction.java @@ -33,7 +33,6 @@ import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; import java.util.Arrays;