Two-Directional chat bot connecting Discord and Factorio chats together, written in nodejs. Examples
This bot does not:
- Disable Achievements BY DEFAULT.
- Require mods to run.
The guide below and on the Wiki is made for factorio servers on Linux. Windows guide might be added on a later date.
- A Discord Bot
- A factorio server with RCON enabled
- A factorio server with Logging enabled
- Node.JS V14 (V16 is recommended!)
Head over to Discord's developer page to create a new application
Open this URL and replace CLIENT_ID
in the URL with the Client ID
found on the application's General Information
page. This should now show your bot, select your server to invite the bot there.
Now, the bot should have joined the server, and is currently offline.
Head back to Discord's developer page, select the application again and head over to the Bot
page under the settings tab.
Create a bot by pressing "Add Bot" and copy the token to somewhere for a while. You will need this token later for the bot to connect to Discord.
Keep this token to yourself ONLY!
The Factorio server must have RCON and Logging enabled. Add the following parameters to the run script:
--rcon-port <port>
- Port to use for RCON.
--rcon-password <pass>
- Password for RCON.
--console-log <path-to-file>
- File to log the chat messages in.
Full example, with server parameters:
/opt/factorio/bin/64/factorio --start-server /opt/factorio/saves/map.zip --server-settings /opt/factorio/data/server-settings.json --rcon-port 8080 --rcon-password password --console-log /opt/factorio/Factorio-server.log
Install or update Node.js on Windows: Node.js Installer (Version 14 or higher)
To verify Node is installed run node -v
in a terminal.
Install or update Node.js on Linux by running these 2 commands:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt -y install nodejs
To verify Node is installed run node -v
in a terminal.
Clone or download the repository.
Navigate to the containing folder and run npm install
to install required packages.
Run git clone https://github.com/AGuyNamedJens/FactorioChatBot
in the folder in which to clone the repository to.
New changes can be fetched by running git pull
in the directory periodically.
Grab the newest stable release FactorioChatBot.zip at the Releases
Unzip the ZIP file.
Go back to your terminal.
cd <repo name>
to navigate to the folder you have the Factorio Chat Bot uploaded at.
Run the following command within that directory to install the required packages.
npm install
Please note that releases are not commonly distributed, so cloning and pulling the repo is recommended to keep up-to-date with changes.
See CONFIG for configuring the bot!
This will however stop the bot as soon as you hit CTRL+C or exit the terminal.
node .
or node FactorioChatBot.js
.
This will keep the bot running when you exit the terminal. Follow the guide below or press the link on installing and setting up PM2
Run the following command as root to install pm2 globally:
npm install pm2@latest -g
After pm2 has been installed, you should be able to start the bot by running the following command in the dir of the bot:
pm2 start index.js --name factoriochatbot
(You can change the name)
To manage the newly created process, these commands exist:
pm2 restart app_name
,
pm2 reload app_name
,
pm2 stop app_name
and
pm2 delete app_name
For listing all applications:
pm2 [list|ls|status]
There is a way to view logs, which you can access by running:
pm2 logs app_name
and pm2 logs app_name --lines 200
to dig into older logs.
To have the bot automatically start when the server itself reboots, run the following command:
pm2 startup
Follow the instructions in the output to schedule the service depending on your system. For example, on Ubuntu 20.04, the output should look similar to:
[PM2] Init System found: systemd [PM2] To setup the Startup Script, copy/paste the following command: sudo env PATH=$PATH:/usr/local/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u defaultuser --hp /home/defaultuser