Skip to content

Instantly share code, notes, and snippets.

@Nordskog Nordskog/instructions.md
Last active Apr 25, 2019

Embed
What would you like to do?
DiscordIRCd instructions

DiscordIRCd is a nodejs app that will create a local irc server you can connect to that pipes through messages from Discord.
This guide assumes you are on windows, though the steps would basically be the same on linux.

General steps:

  1. Get your Discord token
  2. Install node
  3. Download DiscordIRCd
  4. Configure DiscordIRCd
  5. Setup DiscordIRCd
  6. Run DiscordIRCd
  7. Connect with irc ( I will be using mIRC )
  8. Setup DiscordIRCd to run in the background on boot ( optional )

1. Get your Discord Token

Video guide: https://streamable.com/cutu3

Your Discord token is not your password, but it does provide complete access to your Discord account.
DiscordIRCd need this so it can connect to discord on your behalf.
Discord doesn't really intend for you to do this, so it's a bit of a pain.

  1. Open Discord and navigate to Home.
  2. Press ctrl + shift + I. This will open the inspector.
  3. Move to the "Application" tab in the inspector and expand "local storage" in the left-side menu.
  4. Select "https://discordapp.com". This will list all the information stored in local storage on the right.
  5. Press ctrl + R in the discord window. Discord will reload.
  6. At the very bottom of the window on the right you should find an entry named "token". This is your token, copy it for later.

This token will probably be invalidated if you log out of discord on this machine.

2. Install Node

Head over to https://nodejs.org/en/download/ and download the appropriate installer for your system.
Follow the install instructions, default everything should be fine.

3. Download DiscordIRCd

DiscordIRCd is just a folder with some files in it, which you use node to execute.
Go to https://github.com/creesch/discordIRCd and click the "Clone or download" button on the right.
From there you can Download ZIP. Extract it somewhere convenient.
The rest of this guide will assume that the meat of the zip ( server.js and the other files ) are located at C:\bin\discordIRCd

4. Configure DiscordIRC

Video guide: https://streamable.com/py20z

Locate the file "config_example.js" and rename it to "config.js". Make any necessary changes to it.

Below is the config file I have am using, with a bogus discordToken. I have added comments to the bits that matter.

global.configuration = {
    DEBUG: false,   // We don't need to debug anything
    showOfflineUsers: true, // When true all users will always be shown. Offline users will be shown as away on clients that support away-notify.
    discordToken: 'AAAAAAAAAAAA.BBBBBBBBB.CCCCCCCCCCCC',  // Insert your discord token here, inside the quotes. 
    tlsEnabled: false,  // Probably for tls (encryption) between you and the local irc server. Honestly pointless since you're hosting and connecting to yourself. False is fine.
    tlsOptions: {       // Doesn't matter because disabled
      keyPath: '/path/to/key.pem',
      certPath: '/path/to/cert.pem'
    },
    discord: {
      messageLimit: 0   // Number of old message that will be displayed when you connect.
    },
    handleCode: false,    // Parsing of in-chat code blocks. Not really needed. Enable if you want.
    githubToken: '<TOKEN>',   // Why would it need this?
    ircServer: {              // Info for the local irc server you will be connecting to.
        listenPort: 6667,       // The port it will be running on. Default irc port 6667 is fine unless you are running something else there.
        hostname: 'hfydiscord', // This doesn't seem to matter, we'll be connecting to localhost. Will appear in status window though.
        username: 'Roughy'      // Must be the same username you use in irc
    }
};

5. setup DiscordIRCd

Video guide ( 5 & 6 ): https://streamable.com/xktx3

  1. Open the folder you extracted the files to in using explorer. server.js should be in this folder.
  2. Shift + Right-click and select "open command window here". A black command window should open up.
  3. type in "npm install" without the quotes and hit enter. This will install the dependencies of DiscordIRCd.

6. Run DiscordIRC

We're still in the black command window.

Type in "node server.js" without the quotes and hit enter to execute the DiscordIRCd.

It shouldn't really display anything, but because it's a bit old you should get a single deprecration warning.

For now this will run inside the command window, meaning you will need to keep that open in the background.
We'll cover how to have it run in the background, and run automatically on boot, at the end.

7. Connect with irc ( I will be using mIRC )

Video guide: https://streamable.com/crkp5

At long last we can configure the server we'll be connecting to in the irc client.
In the case of the mIRC, you will go to [Options] - [ Connect - Servers ] - Add - and fill in the following information:

Description: Discord ( Doesn't matter, this is just the server name )
Address: localhost ( connect to this computer, same as 127.0.0.1 )
Ports: 6667 ( Or whatever you configured earlier )
Group: HFY ( Doesn't matter )
Password: 551515299237855248 ( This is the ID of the r/HFY Discord server. )

Login Method: None
Password: (optional) (Empty)

Remember that your username must match what you wrote in the config file earlier.
Connect to the server and you should be good to go.

Once connected, the channels you can join match the channel names in the discord server:

#general #writing

and so on. When you are mentioned in channel you have not joined, you will receive a PM from the DiscordIRCd.

Discord handles PMs between users globally, rather than per-server.
If you want to receive those via irc, you have to create another server like above, but "DMserver" in the password field instead of the r/hfy discord server ID.
See the https://github.com/creesch/discordIRCd readme for more info.

8. Autorun and background

Ideally we want this to run in the background, and also run automatically on boot, so all we have to do is connect to the irc server.

There are a number of ways of accomplishing this, but the eaiest is probably to use the Task Scheduler.

  1. Right click on [Computer] in the [start menu], and select [Manage].
  2. In the left hand menu, navigate to [System Tools] - [Task Scheduler] - [Task Scheduler Library].
  3. Select [Create Basic Task], and nae it "DiscordIRC" before clicking next.
  4. Select "When I log on" as the trigger.
  5. Select "Start a Program" as the action.
  6. Paste [ cmd /c node "C:\bin\discordIRCd\server.js" ] WITHOUT THE BRACKETS into the program/script field.
  7. Click next, and click okay when it asks you if you want to launch cmd with /c node "C:\bin\discordIRCd\server.js" as the arguments.
  8. Check the "Open the properties dialog for this task when I click Finish", and click [Finish]
  9. In the newly opened properties window, set the task to "Run whether user is logged on or not". This will make it run in the background.
  10. Move to the [Conditions] tab and uncheck everything.
  11. Move to the [Settings] And uncheck everything BUT "Allow tasks to be run on demand".
  12. Set the drop down menu at the bottom to "Do not start a new instance" ( Should be default )
  13. Click OK to finish configuring the task.

DiscordIRCd should now fire up on boot. You can also launch it immediately by selecting it from the list, and hitting the "Run" item in the right-left menu.

Known issues: DiscordIRCd will crash when you join a new server. If you are using the service to have it launch on boot you will have to go manually fire it up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.