madmax3365 / node-red-node-discord

Discord nodes for node-red
6 stars 9 forks source link

Send Messages not working with DM channels #14

Open tzwartfv opened 4 years ago

tzwartfv commented 4 years ago

The Problem:

When the discord send messages node is used to send a message to a direct message (DM) channel, an error occurs:

Couldn't send to channel '<Channel Number>': channel not found.

Reproducing the Error:

For this error to occur, I have a simple flow consisting of a discord get messages node, leading into a function node that reads:

message = {
    payload: "Anything",
    channel: msg.channel.id
}
return message;

Which then outputs into a discord send messages node.

When a message is sent to the bot in a server channel, the response is as expected, with the bot replying "Anything". However, when a message is sent to the bot through a DM channel, the error occurs.

The Flow:

[
    {
        "id": "65a5b58f.3f8704",
        "type": "tab",
        "label": "Discord Reply Flow",
        "disabled": false,
        "info": ""
    },
    {
        "id": "5416c1c8.c5d9d",
        "type": "discord-get-messages",
        "z": "65a5b58f.3f8704",
        "name": "",
        "token": "",
        "channels": "",
        "x": 108.125,
        "y": 422.5,
        "wires": [
            [
                "d89ad182.49c57"
            ]
        ]
    },
    {
        "id": "113fd53a.8094f3",
        "type": "discord-send-messages",
        "z": "65a5b58f.3f8704",
        "name": "",
        "channel": "",
        "token": "",
        "x": 513.625,
        "y": 422.5,
        "wires": []
    },
    {
        "id": "d89ad182.49c57",
        "type": "function",
        "z": "65a5b58f.3f8704",
        "name": "",
        "func": "message = {\n    payload: \"Anything\",\n    channel: msg.channel.id\n}\nreturn message;",
        "outputs": 1,
        "noerr": 0,
        "x": 314.375,
        "y": 422.5,
        "wires": [
            [
                "113fd53a.8094f3"
            ]
        ]
    }
]
madmax3365 commented 3 years ago

Yep. Sending DM functionality not yet implemented. I was planning to add this feature and update discord.js to the latest version, but for now, I can't find time for this.