Closed flamingm0e closed 3 years ago
Hi! Sorry for the extremely late response; I've been moving to another country and this issue slipped through the cracks :)
There's currently no way of doing this, and the way this works in Discord.js makes it somewhat difficult to integrate well with Node-RED without potentially breaking things. Node-RED sort of requires messages to be JSON-encodable, otherwise things like splitting, joining and duplicating messages doesn't work correctly. Discord.js's message structures aren't JSON-encodable, so for proper support I'd have to come up with my own intermediate message format which is then handled completely by the discordSendMessage
node.
Maybe there's another easier way of doing it, though.. I'd have to look into it in a bit more detail.
For others searching for this, it works now by settting the msg.attachment to the file/URL location.
Here's my function I use to request a webcam image on output 1, waits 2 seconds then sends it to discord on output 2
var channel = msg.channel.id;
msg1 = {payload: "GET"} node.send([msg1, null]) node.status({fill:"blue", shape:"ring", text:'taking pic'});
setTimeout(function(){ node.status({fill:"green", shape:"ring", text:"sent"}); msg2 = {payload: 'Here it is', attachment:"/file/picture.jpg", channel: {id : channel}}; node.send([null, msg2]); }, 2000);
node.on('close', function() { // tidy up any async code here - shutdown connections and so on. });
Is there any way to send a binary buffer through from an HTML call? I have a notification that goes and grabs a camera still shot and sends it to telegram, but I would like to be able to do this with Discord.