Attaching PNG buffers directly to embed.
I've been working with getting a verification system setup, Playing around with canvas and other libraries. I'm at the point where I have a return from another handler returning (text=the captcha code; imageBuffer=the PNG buffer.)
I assumed I could just create an attachment directly from the buffer but I appear to have been wrong as in the embed sent, no image, nilch...
-# See attached file for reference to command handler function file with the code referred to in my query.
35 Replies
- 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!
- ✅
Marked as resolved by OPI will add that the handler that processes the embed messages isn't the issue here, I just went to test that and it handles fine. It's specifically this command file where I'm passing the buffer 💜
Oh and another one, Why does d.js have a defer interaction endpoint. What is the use case of that, why would you ever want to defer an interaction?
because discord has that endpoint. It is for when you cant respond within 3 seconds
Ahh I see I see
Pastebin
const globalClient = require('../../client.js');const { AttachmentB...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Anyway! If you do want to lend a hand I'd love to borrow your brain on the captcha issue <3
Can we see the generate function?
Ah yeah sure, let me pop it on a pastebin! ^^
Pastebin
const globalClient = require('../../../client.js');const svgCaptcha...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
In your generate function have you tried logging
captcha
and svguffer
to make sure they're correct?Yeah, They're all as expected, None are null
I should have mentioned it but passing it directly as a attatchment not in an embed, it works fine
I'll go double check again though, It was a few hours ago that I tested that
Sorry just wanted to be sure
Yeah, it's only in an embed for some reason
Hmm, I doubt it'll be the issue as I think they're processed at the same time anyway, but can you try putting
files
before embeds
?
Also try logging Buffer.isBuffer(attachment)
.. though the buffer is clearly validI'll go give it a go!
If that doesn't work, can we see
globalClient.embedHandler.send()
i think that will always return false? (correct me if im wrong) because
attachment
is a typeof AttachmentBuilder
. i think what you were looking for is attachment.attachment
Right sorry, I meant on the actual buffer returned from the generate function
but can you try putting files before embeds?Just ran that test, Same outcome. Content of buffer: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 01 2c 00 00 00 96 08 06 00 00 00 64 5b b5 d2 00 00 00 09 70 48 59 73 00 00 0b 13 00 00 0b 13 01 ... 24822 more bytes> It just contains the binary of the converted png well... converted svg (to png)
Alright, let's see this
Pastebin
// src/modules/functions/handlers/embedHandler.jsconst { EmbedBuild...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
What confuses me is that, when using the handler for.. well images by URI
wait..
it's just clicked
am i not handling attatchments
god damn it i don't think i am
:TheVoices:
IM NOT LMAO?!
I am confusing myself now pff
Your messageOptions isn't handling
files
yeah
Yep... welp, thank you two for dealing with my idiocy 💜
I have moments like this lmao
well, easy fix! im happy
It happens. I am curious though, why such a roundabout way of handling message options like that anyway?
Nice!
I get that a lot actually, I have minor OCD, I really don't like writing the same code again and again and again. So I send to modularise my code into handlers
It also helps me keep the program organised and scalable
It takes more effort to do, but I find it's just a teeny bit more easy for me to work with
That's fair. If it works for you that's all that really matters. Was just curious 🙂 best of luck
💜