Markoudstaal / node-red-contrib-discord-advanced

Recieve, send, edit and delete Discord messages in node-red.
MIT License
46 stars 16 forks source link

On or after 3.4.5 sending a message with discordMessageManager seems not working #99

Open seaweedsoup opened 9 months ago

seaweedsoup commented 9 months ago

Hi,

First, thank you for your contributing to this awesome node-red palette.

After upgrading on or after 3.4.5, it seems that discordMessageManager is not working properly.

Issues

I use this plugin to send home-related notifications to my phone and it has been working pretty well until now. When I upgraded to 3.5.0 I got an error message like below although I still have the discord token. I downgraded to 3.4.5 and got the same error.

Once I downgraded to 3.4.4, everything worked fine again.

Please let me know if you need any additional info from me.

Running environment

Input

{"_msgid":"99677e8df55638d8","payload":"1694902341539 - 3:12:21 PM","topic":""}

Error

{"message":"Error: Expected token to be set for this request, but none was present","source":{"id":"6ac0a9371635dffe","type":"discordMessageManager","name":"cam-alert channel","count":1},"stack":"Error: Expected token to be set for this request, but none was present\n    at _REST.resolveRequest (/data/node_modules/@discordjs/rest/dist/index.js:1292:15)\n    at _REST.queueRequest (/data/node_modules/@discordjs/rest/dist/index.js:1252:46)\n    at _REST.request (/data/node_modules/@discordjs/rest/dist/index.js:1218:33)\n    at _REST.get (/data/node_modules/@discordjs/rest/dist/index.js:1174:17)\n    at ChannelManager.fetch (/data/node_modules/discord.js/src/managers/ChannelManager.js:123:41)\n    at getChannel (/data/node_modules/node-red-contrib-discord-advanced/discord/discordMessageManager.js:73:37)\n    at createChannelMessage (/data/node_modules/node-red-contrib-discord-advanced/discord/discordMessageManager.js:112:41)\n    at createMessage (/data/node_modules/node-red-contrib-discord-advanced/discord/discordMessageManager.js:140:19)\n    at discordMessageManager._inputCallback (/data/node_modules/node-red-contrib-discord-advanced/discord/discordMessageManager.js:297:19)\n    at /usr/s..."}
javis86 commented 9 months ago

Could you run this and tell me what version of discord.js is nodered using? cat /data/node_modules/discord.js/package.json | grep version

I think there is a conflict between discord js versions when you use the library and you run the fllow for commands creation.

image

When you downgrade the node version, it matches with function node installed discord version and It works for you

seaweedsoup commented 9 months ago

Hello,

I ran

cat /data/node_modules/discord.js/package.json | grep version

on multiple combinations and the results are below (run in docker).

FYI, I didn't set any Modules on my function node. It currently has nothing since I didn't know I could set it in that way. :)

3.4.4 & nodered/node-red:3.0.2-16

0837a2b96a80:~$ cat /data/node_modules/discord.js/package.json | grep version
  "version": "14.13.0",

3.5.0 & nodered/node-red:3.0.2-16

0837a2b96a80:~$ cat /data/node_modules/discord.js/package.json | grep version
  "version": "14.13.0",

3.5.0 & nodered/node-red:latest-16

e22dd1c95194:~$ cat /data/node_modules/discord.js/package.json | grep version
  "version": "14.13.0",

3.4.4 & nodered/node-red:latest-16

e22dd1c95194:~$ cat /data/node_modules/discord.js/package.json | grep version
  "version": "14.13.0",
javis86 commented 9 months ago

I create a new nodered instance from nodered 3.1.

In the following flow the feature is working:

[ { "id": "c557ca4ad41d1528", "type": "inject", "z": "f6f2187d.f17ca8", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 230, "y": 380, "wires": [ [ "030233156029af06" ] ] }, { "id": "f46b0357e8ceeebd", "type": "discordMessageManager", "z": "f6f2187d.f17ca8", "name": "", "channel": "954798049358671922", "token": "", "x": 610, "y": 380, "wires": [ [] ] }, { "id": "030233156029af06", "type": "function", "z": "f6f2187d.f17ca8", "name": "function 1", "func": "msg = {\n _msgid:\"99677e8df55638d8\",\n payload:\"1694902341539 - 3:12:21 PM\",\n topic: \"\"\n };\n \nreturn msg;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 400, "y": 380, "wires": [ [ "f46b0357e8ceeebd" ] ] } ]

Could you try creating a new config node with the same token?

seaweedsoup commented 9 months ago

I create a new nodered instance from nodered 3.1.

Are you talking about new palette or new docker image? I assume you are talking about new palette and can you tell me how to get it? Also, please let me know what version of docker image, I need to test.

Thanks.

javis86 commented 9 months ago

No, I run a new nodered docker container form nodered version 3.1. I installed node-red-contrib-discord-advanced version 3.5.0 from palette, and executed the flow without any error.

docker run -it -p 1880:1880 --name mynodered nodered/node-red

seaweedsoup commented 9 months ago

Oh, I see what you mean. The problem is that I need to run node version 16 due to one of palette I'm using and it requires node version 16. As far as I know, nodered/node-red (== nodered/node-red:latest) and nodered/node-red-16 (== nodered/node-red:latest-16) both use the 3.1.0. nodered/node-red:latest-16 uses node red 3.1.0 but node version is 14. You can see image variant in https://github.com//node-red/node-red-docker under image variant section.

Unfortunately, I cannot run my node-red docker under nodered/node-red:latest because of my palette. Can you try to run under nodered/node-red:latest-16? If you are not able to run, I can try later today or tomorrow since I need to set up a different node red instance.

seaweedsoup commented 9 months ago

Hmm.. it looks like that nodered/node-red:latest may be the version 16. According to https://github.com//node-red/node-red-docker in Manifest Lists and nodered/node-red docker moved default node version to 16. If so, I'm was actually testing on nodered/node-red:latest.

seaweedsoup commented 9 months ago

I did test again on nodered/node-red:latest with 3.5.0 of palette. I'm getting the same error like above I mentioned.

I also copy and paste your node items used for testing into mine and updated channel ID and token but still failing with the same error on node.

seaweedsoup commented 9 months ago

I'm not a super expert on this docker/node-red palette but I wonder if it's due to upgrading from the older version to the latest version? I have been using this docker image and palette from a very old version for a long time (I believe more than 1 year).

javis86 commented 9 months ago

I continue thinking, It may be an data error, because with a fresh new container i don´t have this error and nobody else is reporting it.

seaweedsoup commented 9 months ago

Hmm.. if that's the case, do you know how to validate it? The odd thing is though, without changing data, just changing the version of the palette would change the behaviour.

javis86 commented 8 months ago

Check this #100, plz

seaweedsoup commented 8 months ago

I will try this weekend. Thank you for the info!

moseisleydk commented 7 months ago

Any luck, I have recreated nodes etc, still not works for me, I am getting:

Error: Expected token to be set for this request, but none was present

javis86 commented 7 months ago

Any luck, I have recreated nodes etc, still not works for me, I am getting:

Error: Expected token to be set for this request, but none was present

Did you check this options on discord developer portal image

oskapt commented 3 months ago

FWIW I also ran into this today. I had tried to install this module earlier but found that I needed to upgrade Node-RED first. After upgrading and then installing the module, it wouldn't work and gave me the error above, despite discord.js being the correct version.

Uninstalling node-red-contrib-discord-advanced and reinstalling it resolved whatever the issue was.