SLBot is a Discord bot for managing an SCP: Secret Laboratory (SCP:SL) game server via Discord slash commands. It supports starting, stopping, restarting the server (soft/hard), managing rounds, fetching logs, issuing console commands, and even rebooting the host machine.
/startserver,/stopserver,/restartserver,/roundrestart,/restartnextround,/softrestart/setserverstate <private|public>to toggle server visibility (server must be verified)/onlineplayerslists active players/fetchlogsretrieves recent server console logs/console <command>executes admin console commands in tmux/systemrebootgracefully shuts down SCP:SL and reboots the host
- Python 3.10+ (tested on 3.12)
- A running SCP:SL server managed via
tmuxnamedscpsl, running on port 7777, with files at/home/steam/steamcmd/scpsl - A Discord bot token and a server (guild) ID
- Optional: A Discord webhook URL for command logging
- Clone or copy the repository:
git clone https://github.com/Kf637/SLBot.git cd SLBot - Create a virtual environment (recommended):
python3 -m venv .venv source .venv/bin/activate - Install Python dependencies:
pip install -r requirements.txt
-
Copy the environment file and fill in your credentials:
Edit
.env:DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN GUILD_ID=YOUR_DISCORD_SERVER_ID WEBHOOK_URL=YOUR_WEBHOOK_URL # optional
Note: If
DISABLE_CONSOLEorDISABLE_FETCHLOGSare not defined in your.env, those commands will be disabled by default. To enable them, add the following lines to your environment file:DISABLE_CONSOLE=false DISABLE_FETCHLOGS=false
-
Update
permission.jsonwith the Discord role IDs authorized for each command. Example:{ "restartserver": [123456789012345678], "restartnextround": [123456789012345678], ... }
Run the bot with:
python bot.pyTo run SLBot as a background service, create a systemd unit file at /etc/systemd/system/slbot.service with your bot path:
[Unit]
Description=SLBot Discord Bot
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /path/to/SLBot/bot.py
ExecStop=/usr/bin/pkill -f '/path/to/SLBot/bot.py'
KillMode=process
TimeoutStopSec=10s
Restart=always
[Install]
WantedBy=multi-user.targetThen reload and start the service:
sudo systemctl daemon-reload
sudo systemctl enable slbot.service
sudo systemctl start slbot.service
sudo systemctl status slbot.service- Ensure the bot has the
applications.commandsandbotscope in your Discord application settings. - The server management commands rely on a
tmuxsession namedscpsl. Adjust the session name inbot.pyif yours differs. - The
/systemrebootcommand requires the host user to have passwordlesssudo rebootprivileges.
This project is licensed under the MIT License.













