Welcome to PTBot β your Discord-powered remote control for Pterodactyl game servers! π
PTBot is a Go-based Discord bot that lets you manage your Pterodactyl servers directly from Discord. Whether you want to start, stop, restart, check status, or send console commands, PTBot has you covered. It's like having a sysadmin in your pocket (or at least in your Discord sidebar).
- Slash Commands: Use
/ptto list servers, check status, start, stop, restart, or send commands. π¬ - Autocomplete: Server names autocomplete for fast, typo-free ops. π
- Role & User Restrictions: Only the cool kids (or the ones you allow) can use the bot. π
- Channel Restrictions: Optionally restrict bot usage to specific channels. πΊ
- Health Checks: PTBot keeps an eye on your Pterodactyl panel and sends alerts if things go sideways.
β οΈ - Configurable: Set up via config file or environment variables. Supports allowlists for guilds, roles, users, and channels.
- Per-user API keys: Users can set their own Pterodactyl API key so their own server access and permissions apply.
- Stored encrypted-at-rest on the bot host. The encryption key is provided via PTBOT_TOKENS_SECRET (preferred) or a 32-byte key file at /data/user_tokens.key.
/pt listβ See all your servers π/pt status name:<server>β Get server status π©Ί/pt start name:<server>β Start a serverβΆοΈ /pt stop name:<server>β Stop a server βΉοΈ/pt restart name:<server>β Restart a server π/pt send name:<server> command:<cmd>β Send a console command π»/pt backup name:<server> [backup_name:<text>] [ignored:<patterns>] [lock:true|false]β Create a backup π§°/pt key value:<token|clear>β Set your personal Pterodactyl API key, orclearto remove it π
- Build the bot (see Dockerfile for details)
- Configure your Discord token, Pterodactyl URL, and other secrets in
/data/config.jsonor environment variables. - Invite the bot to your Discord server.
- Profit (or at least enjoy easier server management).
You can run PTBot easily using Docker or Docker Compose. This is the recommended way for production deployments.
services:
ptbot:
image: ghcr.io/jacoknapp/ptbot:latest
container_name: ptbot
restart: unless-stopped
volumes:
- ./data:/data
environment:
DISCORD_TOKEN: <your-discord-bot-token>
PTERO_BASE_URL: <your-pterodactyl-url>
PTERO_CLIENT_TOKEN: <your-pterodactyl-client-api-token>
ALERT_CHANNEL_ID: <discord-channel-id-for-alerts> #optional
HEALTH_CHECK_INTERVAL: 2m #optional
ALLOWED_GUILD_IDS: <comma-separated-guild-ids> #optional
ALLOWED_ROLE_IDS: <comma-separated-role-ids> #optional
ALLOWED_USER_IDS: <comma-separated-user-ids> #optional
ALLOWED_CHANNEL_IDS: <comma-separated-channel-ids> #optional
PTBOT_INSECURE: false #optional, set to true to allow untrusted TLS certs, env only
command: ["-config", "/data/config.json"]- Copy the example above to
docker-compose.yml. - Fill in your secrets and settings (optional if using config).
- Run:
docker compose up -d
You can also run PTBot directly with Docker:
docker run -d \
-v $(pwd)/data:/data \
-e DISCORD_TOKEN=... \
-e PTERO_BASE_URL=... \
-e PTERO_CLIENT_TOKEN=... \
-e ALERT_CHANNEL_ID=... \
-e HEALTH_CHECK_INTERVAL=2m \
-e ALLOWED_GUILD_IDS=... \
-e ALLOWED_ROLE_IDS=... \
-e ALLOWED_USER_IDS=... \
-e ALLOWED_CHANNEL_IDS=... \
-e PTBOT_INSECURE=false \
ghcr.io/jacoknapp/ptbot:latest -config /data/config.json- Create a Discord Application
- Go to Discord Developer Portal
- Click "New Application" and give it a name
- Add a Bot User
- In your application, go to "Bot" and click "Add Bot"
- Copy the bot token and set it as
DISCORD_TOKEN
- Invite the Bot to Your Server
- Go to "OAuth2 > URL Generator"
- Select "bot" and "applications.commands" scopes
- Set permissions (at minimum: Send Messages, Use Slash Commands)
- Copy the generated URL and open it in your browser to invite the bot
- Configure Allowed Guilds, Roles, Users, Channels (optional)
- Use the environment variables to restrict access
To use PTBot, you'll need a Pterodactyl Client API key. Here's how to get one:
- Log in to your Pterodactyl panel as the user who owns the servers you want to control.
- Click your profile icon (top right) and select "API" from the dropdown menu.
- Click "New API Key".
- Enter a name/description for the key (e.g., "PTBot") and set any desired IP restrictions.
- Click "Create".
- Copy the generated API key and use it as the value for
PTERO_CLIENT_TOKENin your PTBot configuration.
Note: Keep your API key secret! Anyone with this key can control your servers via PTBot.
- Run
/pt key value:<your-token>to save your key securely on the bot host (encrypted-at-rest depends on filesystem; stored with 0600 permissions). From now on, your/ptcommands will use your key. - Run
/pt key value:clearto remove it and fall back to the bot's default key. - For best security, set PTBOT_TOKENS_SECRET in the container environment. Alternatively, mount a 32-byte raw key file at /data/user_tokens.key.
PRs welcome! If you have a fun idea (or just want to add more emojis), fork away. π¦
"Why click buttons when you can
/pt startlike a boss?"
Made with β€οΈ, Go, and Discordgo.
MIT License
Copyright (c) 2025 jacoknapp
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
