I'm trying to upload a PNG image via JDA, and can't get it to work. Using a File to the .png on my desktop, reading the file to a byte[], both result in nothing happening at all. No errors in the log, the image never appears though.
Am I missing something? thanks!
How are you trying to send the file? Please provide more information.
Cannot reproduce, I'm using version "3.1.1_212" (I will try reproducing this with "3.1.1_213" soon)
context.sendFile(new File(Loritta.FOLDER + "angel.png"), "angel.png", new MessageBuilder().append(" ").build());
And via input stream
val os = ByteArrayOutputStream()
ImageIO.write(blackWhite, "png", os)
val inputStream = ByteArrayInputStream(os.toByteArray())
context.sendFile(inputStream, "undertale_battle.png", " ");
EDIT: Whoops, I forgot that I use an external class to send files
File:
event.getTextChannel().sendFile(file, name, message).complete();
InputStream:
event.getTextChannel().sendFile(data, name, message).complete();
@MrPowerGamerBR You forgot to .queue(), sendFile() returns a RestAction.
classic
@Almighty-Alpaca but I said that I cannot reproduce this issue 🤷 Sending images is working fine to me 😉
I use an external class to handle message sending so I can apply some per-guild configurations (and I forgot that when I sent the code I was using here 😋, I then edited my message to show the "real" code I was using "behind the scenes")
I just mentioned it so nobody comes and blames that example to not work
I'm using channel.sendFile(new File("E:\\image.png"), "png", null).queue();. Adding a file name (channel.sendFile(new File("E:\\image.png"), "image.png", null).queue();) doesn't help either.
Have you checked what the call returns? Inside of queueas callback or the result of complete.
You are not seeing anything at all in the channel, right?
Nope, nothing. I put a System.out.println("yay"); inside the callback, but nothing.
Then i suspect that your file-send code is not even reached and that its not a fault of the sendFile function at all
Actually, I forgot to close the bot process, and now (20 minutes after it sent!!!) i got this in the log:
and no, a System.out.println directly before the sendFile confirms that it IS getting there
the image is only 100KB, before you ask
Could you try reading the file yourself and providing the data as either an InputStream or byte[] to sendFile together with the file name?
as i said, i already tried with a byte[] to no avail, and adding the image name didn't help.
Does this happen for every image or just a specific image file?
i've tried 6 different ones, 2 jpegs and 4 pngs
@DaMatrix Are you still experiencing this? Can anyone else reproduce this issue?
sorry, i should have closed it. it was caused by a hardware issue, the drive with the images on it wasn't connected properly. it seems to work fine now.
Most helpful comment
@MrPowerGamerBR You forgot to
.queue(), sendFile() returns a RestAction.