A simple Python Discord bot designed to be hosted on the same hardware as a Minecraft server, allowing it to update the whitelist.json file. This bot was created for a friend who set up a Minecraft server so that members of their Discord could self-whitelist.
sudo apt install python3 python3-venv- Update Package lists
sudo apt update- Upgrade the System (optional but recommended):
sudo apt upgrade- Install python3-pip
sudo apt install python3-pip- Clone the repository:
git clone https://github.com/Infinity585/Discord_Minecraft_Whitelisting.git- Navigate to the repository directory: Change into the repo directory
cd Discord_Minecraft_Whitelisting/- Set up a Python Virtual Environment:
python3 -m venv env
source env/bin/activate- Install Python dependencies:
pip3 install -r requirements.txt- Configure the .env file:
nano .env- Paste in and fill out the fields:
token = (discord bot toekn)
applicationid = (discord applicationid)
jsonPath = (full path)
logChannel = (discord channel id)
- Press to exit
ctrl + x
- Save changes (Save modified buffer?)
y
- Write to file (File Name to Write: .env)
Enter
Run the bot:
Python3 main.py- Start a screen session:
screen -S minecraftDiscordBot- Navigate to the repository directory
cd Discord_Minecraft_Whitelisting/- Enter the Virtual Environment
source env/bin/activate- Run the program
python3 main.pyThe bot should now be running, and the SSH terminal can be safely closed.
To list screen sessions:
screen -lsTo reattach a session:
screen -r <id or name>/whitelist <minecraft username>