Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot upload files larger than 8MB on boosted guilds #2005

Closed
3 tasks done
wajwuz opened this issue Feb 2, 2022 · 2 comments
Closed
3 tasks done

Cannot upload files larger than 8MB on boosted guilds #2005

wajwuz opened this issue Feb 2, 2022 · 2 comments
Labels
bug level: novice is doable as a java/jda novice status: completed has been completed but is not yet released

Comments

@wajwuz
Copy link

wajwuz commented Feb 2, 2022

General Troubleshooting

  • I have checked for similar issues.
  • I have updated to the latest JDA version.
  • I have checked the branches or the maintainers' PRs for upcoming bug fixes.

Bug Report

I'm trying to upload file over 8MB (guild have 3 level) and error occurs.

Expected Behavior

Upload file i think? Also i got this from discord MessageAction#addFile

Code Example or Reproduction Steps

var bytes = response.bodyAsBytes(); // it's a static file on website.

if (bytes.length < clientMessage.getGuild().getMaxFileSize()) {
message.editMessage("msg").addFile(bytes, "tictoc.mp4").queue();

Code for JDABuilder or DefaultShardManagerBuilder Used

JDABuilder.createLight("apptoken")
                    .disableCache(CacheFlag.MEMBER_OVERRIDES, CacheFlag.ACTIVITY, CacheFlag.VOICE_STATE)
                    .disableIntents(GatewayIntent.GUILD_PRESENCES, GatewayIntent.GUILD_MESSAGE_TYPING)
                    .addEventListeners(new MessageReceivedListener())
                    .setMemberCachePolicy(MemberCachePolicy.OWNER)
                    .setActivity(Activity.watching("tictocs."))
                    .setChunkingFilter(ChunkingFilter.NONE)
                    .setBulkDeleteSplittingEnabled(false)
                    .setStatus(OnlineStatus.IDLE)
                    .setAutoReconnect(true)
                    .build()
                    .awaitReady();

Exception or Error

java.lang.IllegalArgumentException: File may not exceed the maximum file length of 8388608 bytes!
	at net.dv8tion.jda.internal.utils.Checks.check(Checks.java:70)
	at net.dv8tion.jda.api.requests.restaction.MessageAction.addFile(MessageAction.java:604)
	at uwu.taiga.listeners.MessageReceivedListener.lambda$downloadVideo$1(MessageReceivedListener.java:57)
	at net.dv8tion.jda.api.requests.Request.lambda$onSuccess$0(Request.java:95)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1434)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
@DV8FromTheWorld
Copy link
Member

What version of JDA are you using?

@freya022
Copy link
Contributor

freya022 commented Feb 4, 2022

The bug was already narrowed down iirc, MessageAction checks for the SelfUser file size limit instead of the Guild's file size limit.

On 5.0.0-alpha.5, MessageAction#addFile(byte[], String, AttachmentOption...) at line 603, defines the data max size as SelfUser#getAllowedFileSize

However, MessageActionImpl#addFile(File, String, AttachmentOption...) does use a private method which does the correct checks

So, potential solutions is to either pull up the MessageAction#addFile(byte[], String, AttachmentOption...) in the implementation class, or duplicate the helper method's code

@MinnDevelopment MinnDevelopment added the level: novice is doable as a java/jda novice label Feb 5, 2022
@MinnDevelopment MinnDevelopment added the status: completed has been completed but is not yet released label Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug level: novice is doable as a java/jda novice status: completed has been completed but is not yet released
Projects
None yet
Development

No branches or pull requests

4 participants