A Discord bot for managing Pterodactyl Panel servers. This bot allows users to link their Discord accounts to the Pterodactyl Panel and create game servers with predefined resource configurations.
/link
command: Authenticates users and links their Discord account to the Pterodactyl Panel/create
command: Creates a new server based on predefined templates/delete
command: Delete one of your servers/reset-password
command: Reset your Pterodactyl panel password/panel-info
command: Get information about the Pterodactyl panel configuration/servers
command: Lists all servers owned by the user/templates
command: Lists all available server templates with their specifications- User limit: Each user can create up to 2 servers
- Automatic allocation creation: The bot automatically finds available nodes and allocations
- Python 3.8 or higher
- A Discord bot token
- A Pterodactyl Panel with API access
-
Clone this repository:
git clone https://github.com/FreeCode911/PteroServerBot.git cd PteroServerBot
-
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Create a
.env
file based on.env.example
and fill in your credentials:cp .env.example .env # Edit the .env file with your favorite text editor
-
Configure your server templates in
config.py
according to your needs.
- Go to the Discord Developer Portal
- Create a new application
- Go to the "Bot" tab and create a bot
- Enable the "Message Content Intent" under Privileged Gateway Intents
- Copy the bot token and add it to your
.env
file - Go to the "OAuth2" tab
- Under "URL Generator", select the following scopes:
bot
applications.commands
- Under "Bot Permissions", select:
- "Send Messages"
- "Embed Links"
- "Use Slash Commands"
- Copy the generated URL and use it to invite the bot to your server
- Log in to your Pterodactyl Panel as an administrator
- Go to "Application API" in the admin area
- Create a new API key with the following permissions:
- Users: Read & Write
- Servers: Read & Write
- Allocations: Read
- Locations: Read
- Nests: Read
- Copy the API key and add it to your
.env
file
-
Start the bot:
python main.py
-
In Discord, use the following commands:
/link
- Link your Discord account to Pterodactyl/templates
- View available server templates/create <template>
- Create a new server with the specified template/servers
- List all your servers
You can customize the server templates in the config.py
file. Each template defines the resources allocated to the server, such as RAM, CPU, and disk space.
Example:
SERVER_TEMPLATES = {
'softerwire': {
'name': 'Softerwire',
'description': 'Softerwire Server',
'memory': 4096, # RAM in MB
'disk': 2048, # Disk space in MB
'cpu': 200, # CPU limit (300 = 3 cores)
'nest': 5, # Nest ID (default is 1 for Minecraft)
'egg': 25, # Egg ID (default is 1 for Vanilla Minecraft)
},
# Add more templates as needed
}