discord-irc

Connects Discord and IRC channels by sending messages back and forth.
Example

Installation and usage
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.
Before you can run discord-irc you need to create a configuration file by
following the instructions here.
After you've done that you can replace /path/to/config.json
in the commands
below with the path to your newly created configuration file - or just config.json
if it's
in the same directory as the one you're starting the bot from.
When you've done that you can install and start the bot either through npm:
$ npm install -g discord-irc
$ discord-irc --config /path/to/config.json
or by cloning the repository:
In the repository folder:
$ npm install
$ npm run build
$ npm start -- --config /path/to/config.json
It can also be used as a module:
import discordIRC from 'discord-irc';
import config from './config.json';
discordIRC(config);
Docker
As an alternative to running discord-irc directly on your machine, we provide a Docker container image.
After creating a configuration file, you can fetch the image from Docker Hub and run it with the following command:
docker run -v /path/to/config:/config/config.json discordirc/discord-irc
If you've checked out the repository already, you can build the Docker image locally and run that instead:
docker build -t discord-irc .
docker run -v /path/to/config:/config/config.json discord-irc
Note that the path to the config file on the host (/path/to/config
) must be a valid absolute path to a config file.
Otherwise, you may get the error "illegal operation on a directory".
Configuration
First you need to create a Discord bot user, which you can do by following the instructions here.
Example configuration
[
{
"nickname": "test2",
"server": "irc.testbot.org",
"discordToken": "botwantsin123",
"channelMapping": {
"#other-discord": "#new-irc-channel"
}
},
{
"nickname": "test",
"server": "irc.bottest.org",
"discordToken": "botwantsin123",
"autoSendCommands": [
["PRIVMSG", "NickServ", "IDENTIFY password"],
["MODE", "test", "+x"],
["AUTH", "test", "password"]
],
"channelMapping": {
"#discord": "#irc channel-password",
"1234567890": "#channel"
},
"ircOptions": {
"floodProtection": false,
"floodProtectionDelay": 1000,
"port": "6697",
"secure": true,
"sasl": true,
"username": "test",
"password": "p455w0rd"
},
"format": {
"commandPrelude": "Command sent by {$nickname}",
"ircText": "<{$displayUsername}> {$text}",
"urlAttachment": "<{$displayUsername}> {$attachmentURL}",
"discord": "**<{$author}>** {$withMentions}",
"webhookAvatarURL": "https://robohash.org/{$nickname}"
},
"ircNickColor": false,
"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,
"ignoreUsers": {
"irc": ["irc_nick1", "irc_nick2"],
"discord": ["discord_nick1", "discord_nick2"],
"discordIds": ["198528216523210752"]
},
"webhooks": {
"#discord": "https://discordapp.com/api/webhooks/id/token"
}
}
]
The ircOptions
object is passed directly to irc-upd (available options).
To retrieve a discord channel ID, write \#channel
on the relevant server – it should produce something of the form <#1234567890>
, which you can then use in the channelMapping
config.
Webhooks
Webhooks lets you override nicknames and avatars, so messages coming from IRC
can appear as regular Discord messages:

To enable webhooks, follow part 1 of this
guide
to create and retrieve a webhook URL for a specific channel, then enable it in
discord-irc's config as follows:
"webhooks": {
"#discord-channel": "https://discordapp.com/api/webhooks/id/token"
}
Encodings
If you encounter trouble with some characters being corrupted from some clients (particularly umlauted characters, such as ä
or ö
), try installing the optional dependencies iconv
and node-icu-charset-detector
.
The bot will produce a warning when started if the IRC library is unable to convert between encodings.
Further information can be found in the installation section of irc-upd.
Tests
Run the tests with:
$ npm test
Style Guide
discord-irc follows the Airbnb Style Guide.
ESLint is used to make sure this is followed correctly, which can be run with:
$ npm run lint