jorisvddonk / node-red-contrib-discord

Node-red nodes that allow you to interact with Discord.
15 stars 19 forks source link

No message at empty channel ID in discordSendMessage node #6

Closed Aim23 closed 6 years ago

Aim23 commented 6 years ago

I'm not able to receive messages in a channel, if there is no channel ID present. If a channel ID is present it is working flawlessly. Any suggestions?

jorisvddonk commented 6 years ago

The discordSendMessage node requires there to be a channel property on incoming messages, which should either be a Channel ID or an object with an 'id' key. Such a property is automatically added to messages emitted by the discordMessage node. If there's no such property available, you must specify the channel ID in the discordSendMessage node's configuration.

Probably, what's happening is that the messages received by the discordSendMessage node don't have a channel property. This can happen when, for instance, you've wired in a function node that sends a completely new message (node.send({payload: 'Hello!'})) instead of cloning the original message and sending it (var newMessage = Object.assign({payload: 'Hello!'}, msg); node.send(newMessage);).

Can you verify that the messages received by your discordSendMessage node have a channel property on them?

Aim23 commented 6 years ago

Alright, got that concept! Object.assign didn't worked out for me, had to put {payload: function(), channel: msg.channel, author: msg.author}. This is working now pretty well 👍 :)