"Cannot send an empty message" when sending an image

I am running a bot that tries to display a dynamically rendered image (an XP rank card showing the user's XP amount and rank). This image is loaded from an external server. However, the command often fails with "Cannot send an empty message", even though the message is not empty. Here is the relevant source code: https://gist.github.com/hyper-neutrino/3da6250bbac41d88d63411829e16c4dd. The image is being generated by the server using the Node Canvas and the return value is canvas.toBuffer("image/png") (the server is using Node.JS and Fastify). The thing is, the message is not empty, and in the error message I get, I even see the file data (see attached image; the numbers at the top are the tail end of a massive array of numbers). If I copy the array and just do channel.send({ files: [{ attachment: Buffer.from(array), name: "test.png" }] }), then it actually works, but my command response does not. This error doesn't even happen consistently; sometimes it works and sometimes it doesn't, and there is seemingly no pattern to it at all.
No description
1 Reply
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Want results from more Discord servers?
Add your server