guidone / node-red-contrib-chatbot-discord

Discord Nodes for RedBot
5 stars 2 forks source link

How to send a message to discord? #4

Open pratham2003 opened 4 years ago

pratham2003 commented 4 years ago

Hi,

I have a simple flow. Discord-In -> Message -> Discord-out I'm getting this error.

PrettyJSON error

-- RELAY MESSAGE --
{ There is a valid parsed version of the JSON object here }

I'm not sure why the console says PrettyJSON error

(node:21308) UnhandledPromiseRejectionWarning: TypeError: Cannot assign to read only property 'writeQueueSize' of object '#<TCP>'

pratham2003 commented 4 years ago

For the PrettyJSON error it's was mostly related to a circular reference.

I replaced PrettyJSON with prettyoutput which has a max-depth limit. It works.

UnhandledPromiseRejectionWarning was thrown by node-red's debug module.

Update: So these errors were related to cloning the payload. at _clone in node-red\node_modules\clone\clone.js

I realized the reason node-red was trying to clone the payload was because I had the link setup this way

graph TD
  DR[Discord Receiver]
  DS[Discord Sender]
  SW[Switch]
  TXT[Text]
  DBG[Debug]

  DR --> SW
  SW --> TXT
  TXT --> DS

  DR --> DBG

P.S. Github doesn't have MermaidJS support yet?

I guess the reason it had to 'clone' the message was because I was connecting the Discord Sender to two endpoints.

The error was produced only when I attached the Debug to Discord Sender which initially lead me to believe it was an issue related to debug specifically but after disconnecting DR --> SW the Debug module worked.