reactiflux / discord-irc

Connects Discord and IRC channels by sending messages back and forth.
MIT License
1.2k stars 293 forks source link

2021-04-14T18:46:51.522Z error: Object.entries(...).filter(...).flatMap is not a function #585

Closed b3z closed 1 year ago

b3z commented 3 years ago

I don't know what is going on. This comes when I send a message. I was trying to use the webhook thingy. Without it works just fine. My config:

[{
        "nickname": "StackHub",
        "server": "irc.freenode.net",
        "discordToken": "XXX",
        "autoSendCommands": [
                ["PRIVMSG", "XXX", "Up"]
        ],
        "channelMapping": {
                "#questions": "##stackhub"
        },
        "format": {
                "commandPrelude": "Command sent by {$nickname}",
                "ircText": "<{$displayUsername}> {$text}",
                "urlAttachment": "<{$displayUsername}> {$attachmentURL}",
                "discord": "**<{$author}>** {$withMentions}",
                "webhookAvatarURL": "https://robohash.org/{$nickname}"
        },
        "ircNickColor": true,
        "ircNickColors": ["light_blue", "dark_blue", "light_red", "dark_red", "light_green", "dark_green", "magenta", "light_magenta", "orange", "yellow", "cyan", "light_cyan"],
        "parallelPingFix": true,
        "commandCharacters": ["!", "."],
        "ircStatusNotices": true,
        "webhooks": {
                "#questions": "https://discord.com/api/webhooks/XXX"
        }
}]
Throne3d commented 3 years ago

Hey! I can't seem to reproduce this issue locally when using webhooks.

Could you please provide this information so I can investigate further?

Frosku commented 3 years ago

I'm also getting this error.

NPM version 5.8.0 Node version 10.24.0 discord-irc version 2.9.0

The error is exactly as shown:

$ discord-irc --config config.json
2021-05-09T11:37:00.770Z info: Connected to Discord
2021-05-09T11:37:01.577Z info: Connected to IRC
2021-05-09T11:37:10.747Z error: Object.entries(...).filter(...).flatMap is not a function
Throne3d commented 3 years ago

Ah, I see! I think that explains it: I googled a bit, and flatMap was added in Node 11, so it's not available in Node 10.

Node 10 recently went EOL, so I recommend upgrading your system node for most apps anyway, but in particular, due to our reliance on the discord.js library, we dropped support for old Node versions (6, 8 and 10) in version 2.9.0, in October 2020, which was necessary for some upcoming Discord API changes. We've got a notice in the README, but maybe it's not prominent enough:

Note: discord-irc requires Node.js version 12 or newer, as it depends on discord.js. Future versions may require newer Node.js versions, though we should support active releases.

Could you try upgrading your system Node version, and see if that helps?