Configuration
Overview
Pterodisbot supports two configuration methods:
- config.ini file - Traditional file-based configuration
- Environment variables - For Docker/container deployments
Both methods are validated at startup for required fields and correct formats.
Environment Variables
When using Docker or generating the config automatically, these environment variables are required:
| Variable | Description | Example |
|---|---|---|
DISCORD_TOKEN |
Your Discord bot token from Developer Portal | MTIzNDU2Nzg5... |
ALLOWED_GUILD_ID |
The Discord server ID where the bot operates | 123456789012345678 |
PANEL_URL |
Your Pterodactyl panel URL (must include protocol) | https://panel.example.com |
CLIENT_API_KEY |
Pterodactyl client API key (starts with ptlc_ or pacc_) |
ptlc_abcdef123456... |
APPLICATION_API_KEY |
Pterodactyl application API key (starts with ptla_ or papp_) |
ptla_ghijkl789012... |
Configuration File
The bot uses a config.ini file with this structure:
[Pterodactyl]
PanelURL = https://your.pterodactyl.panel
ClientAPIKey = ptlc_yourclientkey
ApplicationAPIKey = ptla_yourapplicationkey
[Discord]
Token = your.discord.bot.token
AllowedGuildID = 123456789012345678
Pterodactyl Section
| Key | Required | Description | Validation |
|---|---|---|---|
PanelURL |
✅ | Panel URL with protocol | Must start with http:// or https:// |
ClientAPIKey |
✅ | Client API key for server operations | Must start with ptlc_ (Pterodactyl) or pacc_ (Pelican) |
ApplicationAPIKey |
✅ | Application API key for admin operations | Must start with ptla_ (Pterodactyl) or papp_ (Pelican) |
Discord Section
| Key | Required | Description | Validation |
|---|---|---|---|
Token |
✅ | Discord bot token | Non-empty string |
AllowedGuildID |
✅ | Discord server ID | Positive integer |
Generating Config from Environment Variables
To generate the config file from environment variables:
python generate_config.py
This reads the environment variables and writes a config.ini file. Useful for Docker deployments where you want to mount a config file generated at container startup.
Docker Entry Point
The entrypoint.sh script automatically generates config from env vars:
#!/bin/sh
python generate_config.py
exec python main.py
Configuration Validation
The bot performs comprehensive validation at startup:
1. Required Sections Check
[Pterodactyl]section must exist[Discord]section must exist
2. Required Keys Check
All keys listed above must be present and non-empty.
3. Format Validation
| Field | Validation Rule |
|---|---|
AllowedGuildID |
Must be a positive integer |
PanelURL |
Must start with http:// or https:// |
ClientAPIKey |
Must start with ptlc_ or pacc_ |
ApplicationAPIKey |
Must start with ptla_ or papp_ |
4. Panel Type Detection
The bot auto-detects panel type from API key prefixes:
- Pterodactyl:
ptlc_/ptla_(standard) - Pelican Panel:
pacc_/papp_(fork)
Access via Config.is_pelican_panel property.
Sample Configurations
Pterodactyl Panel (Standard)
[Pterodactyl]
PanelURL = https://panel.example.com
ClientAPIKey = ptlc_abcdefghijklmnopqrstuvwxyz123456
ApplicationAPIKey = ptla_zyxwvutsrqponmlkjihgfedcba987654
[Discord]
Token = MTIzNDU2Nzg5MDEyMzQ1Njc4.YzA5YzE.YzA5YzEtYzA5YzE
AllowedGuildID = 123456789012345678
Pelican Panel
[Pterodactyl]
PanelURL = https://pelican.example.com
ClientAPIKey = pacc_abcdefghijklmnopqrstuvwxyz123456
ApplicationAPIKey = papp_zyxwvutsrqponmlkjihgfedcba987654
[Discord]
Token = MTIzNDU2Nzg5MDEyMzQ1Njc4.YzA5YzE.YzA5YzEtYzA5YzE
AllowedGuildID = 123456789012345678
Docker Environment File (.env)
# Discord
DISCORD_TOKEN=MTIzNDU2Nzg5MDEyMzQ1Njc4.YzA5YzE.YzA5YzEtYzA5YzE
ALLOWED_GUILD_ID=123456789012345678
# Pterodactyl Panel
PANEL_URL=https://panel.example.com
CLIENT_API_KEY=ptlc_abcdefghijklmnopqrstuvwxyz123456
APPLICATION_API_KEY=ptla_zyxwvutsrqponmlkjihgfedcba987654
Advanced Configuration
Embed Storage Path
Default: ./embed/embed_locations.json
Can be customized by modifying the Config class in config.py:
self.embed_storage_path: Path = Path("./embed/embed_locations.json")
Update Interval
Default: 10 seconds
Controlled by the background task decorator in bot.py:
@tasks.loop(seconds=10) # UPDATE_INTERVAL = 10
async def update_status(self) -> None:
Required Role
Default: Game Server User
Hardcoded in Config class:
self.required_role: str = "Game Server User"
To change, modify the source code or create a custom config option.
Log Configuration
Controlled in logging_config.py:
- File:
logs/pterodisbot.log - Max Size: 5MB
- Backups: 3 files
- File Level: DEBUG
- Console Level: INFO
Kubernetes Secrets
For Kubernetes deployments, create a secret with all required values:
kubectl create secret generic pterodisbot-config \
--from-literal=DISCORD_TOKEN='your-discord-bot-token' \
--from-literal=ALLOWED_GUILD_ID='your-discord-guild-id' \
--from-literal=PANEL_URL='https://your.pterodactyl.panel' \
--from-literal=CLIENT_API_KEY='ptlc_your-client-api-key' \
--from-literal=APPLICATION_API_KEY='ptla_your-application-api-key' \
-n pterodisbot
Then reference in deployment:
envFrom:
- secretRef:
name: pterodisbot-config
Troubleshooting Configuration
Common Validation Errors
| Error | Cause | Solution |
|---|---|---|
Configuration file not found |
Missing config.ini |
Create file or run python generate_config.py |
Missing [Pterodactyl] section |
Section header missing | Add [Pterodactyl] to config.ini |
PanelURL must start with http:// or https:// |
Missing protocol | Add https:// to panel URL |
ClientAPIKey should start with 'ptlc_' |
Wrong key prefix | Use correct client API key from panel |
AllowedGuildID must be a valid integer |
Non-numeric guild ID | Copy guild ID from Discord (right-click server → Copy ID) |
Testing Configuration
Validate config without starting bot:
python -c "from config import load_config; load_config('config.ini'); print('Config valid!')"
View Current Configuration
python -c "
from config import load_config
config = load_config('config.ini')
print(f'Panel: {config.get_panel_display_name()}')
print(f'Panel URL: {config.pterodactyl_url}')
print(f'Guild ID: {config.allowed_guild_id}')
print(f'Required Role: {config.required_role}')
"
Security Best Practices
- Never commit
config.inito version control - Add to.gitignore - Use environment variables in production - Especially for Docker/K8s
- Rotate API keys periodically - Regenerate in panel if compromised
- Use HTTPS for panel URL - Never use
http://in production - Restrict Discord bot permissions - Only grant required permissions
- Limit "Game Server User" role - Only assign to trusted users
Related Pages
- Architecture - System design
- Installation - Deployment guides
- Usage - Commands and workflows
- Features - Feature details
- Contributing - Development guidelines