This is a self hosted discord rcon bot that lets you execute commands from discord and live view the game chat. It also displays the current player count in the bots activity.
Basic installation steps:
- Create a discord bot (here)
- Install node and npm
- Clone git repository
- Copy and customize config.yml file
- Start the bot
This was tested on a Ubuntu Server 20.04 LXC container. Before you start, create a discord bot (here)
Ensure you have the latest updates
apt update && apt upgrade -y
Install Node.js and NPM
apt install nodejs
apt install npm
Install Git
apt install git
Clone the git repository
git clone https://github.com/koellemichael/discord-rust-rcon-bot.git
cp config-example.yml config.yml && nano config.yml
If you want the bot to restart after a crash or server restart follow these steps: Install PM2
apt install pm2
Make sure that PM2 runs after a reboot
pm2 startup
start the bot
pm2 start --name "discord-rcon-rust-bot" npm -- start
You can alternatively use forever or native systemd.
If you just want to start the bot normally, use: (Note: skip this if you followed the PM2 setup)
npm start
For the bot to run correctly you need to configure the gamesever itself aswell as the bot.
Ensure you have rcon web enabled. (Normally it is enabled on default)
In the gameserver config you need to specify:
rcon.web 1
The configuration file must be named config.yml and placed in the root of the repository directory.
token: "bot token goes here"
chatChannelId: "channel id for the live chat"
commandChannelId: "channel id for command execution"
rconHost: "gameserver ip or domain"
rconPort: "28016"
rconPassword: "your rcon password"
adminRole: "admin role id"
How to create a bot and get the bot token
Messages to chatChannel of users with adminRole are directly forwarded to the server.
Run the bot normally to see the logs:
npm start
If you use PM2 have to stop the bot first:
pm2 stop discord-rcon-rust-bot
You can also monitor the process with pm2 (this displays only current logs)
pm2 monit
The error log should usually give you a hint on what is wrong. You probably forgot to copy the example config file.