Repository navigation
Installation
You need a machine that is always on, for example a VPS, a home server or a Raspberry Pi. It must be able to reach your Crafty Controller and the internet (for Discord).
A separate Crafty user for the bot is recommended.
- Open your Crafty Controller and click on the gear icon in the top right corner.
- Click on add user and enter a name, for example
crafty_bot. Crafty only accepts 3 to 20 lowercase letters, digits or underscores (no spaces). - Fill in the required fields and click on Save.
- Give the user a role that has access to the servers the bot should control (create one with add role if
needed). Without it Crafty returns no servers and
liststays empty. - Click on the pencil icon next to the user, then on API Key, and select these permissions:
-
COMMANDS(start, stop, restart) TERMINALPLAYERS-
BACKUP(only needed for thebackupcommand)
-
- Enter a name for the token, click on Create and save the token. This is your
CRAFTY_TOKEN.
Note
Logging in with CRAFTY_USERNAME and CRAFTY_PASSWORD instead of a token works too, but not for users with
two-factor authentication. A token is recommended.
- Open the Discord Developer Portal and click on New Application.
- Enter a name (for example "Crafty Bot"), accept the terms and click on Create.
- Open Bot in the left-hand menu:
- Disable Public Bot.
- Enable Message Content Intent under Privileged Gateway Intents. The bot needs it for the
>commands and doesn't start without it. - Click on Reset Token, confirm and copy the token. This is your
DISCORD_TOKEN.
- Open OAuth2 → URL Generator:
- Scopes:
botandapplications.commands - Bot permissions: View Channels, Send Messages, Read Message History and Use Application Commands
- Scopes:
- Open the generated URL, select your Discord server and click on Authorize.
The person who owns the Discord application is the bot owner. Only the owner can use backup, sync and the other
admin commands.
docker run -d --name crafty-bot --restart unless-stopped \
-e DISCORD_TOKEN=YOUR_DISCORD_TOKEN \
-e CRAFTY_TOKEN=YOUR_CRAFTY_TOKEN \
-e SERVER_URL=https://YOUR-CRAFTY-HOST:8443 \
-v crafty-bot-data:/usr/src/app/data \
twoplay/craftybot:latestOr with Docker Compose:
services:
crafty-bot:
image: twoplay/craftybot:latest
container_name: crafty-bot
environment:
- DISCORD_TOKEN=YOUR_DISCORD_TOKEN
- CRAFTY_TOKEN=YOUR_CRAFTY_TOKEN
- SERVER_URL=https://YOUR-CRAFTY-HOST:8443
# Optional web dashboard, see the "Web Dashboard" page
# - WEB_ENABLED=true
# - WEB_PASSWORD=YOUR_DASHBOARD_PASSWORD
# ports:
# - "8080:8080"
volumes:
# Keeps the feature flags changed in the dashboard
- crafty-bot-data:/usr/src/app/data
restart: unless-stopped
volumes:
crafty-bot-data:All settings are described on the Configuration page. Update with docker compose pull && docker compose up -d.
Python 3.10 or newer is required.
git clone https://github.com/Two-Play/Crafty-Discord-bot.git
cd Crafty-Discord-bot
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # then fill in SERVER_URL, DISCORD_TOKEN and CRAFTY_TOKEN
python -m coreTo update, run git pull and pip install -r requirements.txt in the project directory and restart the bot.
The > commands work right away. Slash commands only appear after the bot owner runs >sync once, see
Commands.
Setup
Usage
Help