Skip to content

VolumeZero/ptero-bot

Repository files navigation

Welcome to Ptero-Bot 👋

Version Documentation Maintenance

A Discord bot built for managing, monitoring, and interacting with Pterodactyl servers — all directly from Discord.

🏠 Introduction

Ptero-Bot is a powerful, and simple Node.js Discord bot built for Pterodactyl panel users.

Ptero-Bot allows server owners and users to manage their Pterodactyl servers directly from Discord.

It provides real-time server monitoring, detailed embeds, and an interactive server manager UI inside Discord.

Even if you are not the owner of the Pterodactyl panel, you can still use user-specific API keys to manage your own servers through the bot. (Node status embeds will not work without an application API key. Server status will work fine)

✨ Core Features

• Interactive Server Manager

The bot includes a basic server management interface using Discord buttons and embeds:

  • Start / Stop / Restart server
  • View live console logs with the ability to send commands to the server
  • View live resource usage (CPU, RAM, Disk)
  • View server details (ID, Name, Status, Address, Uptime)
  • View SFTP details (username, password, port)
  • WebSocket-powered updates to avoid any rate limits while providing real-time info
  • Disable old sessions automatically when user starts a new one or after a period of inactivity
  • Any user with a linked API key can manage their own servers

Main Server Manager

• Server Status Embeds

  • Compact and detailed server info
  • Power state icon and embed color
  • CPU, RAM, storage, and uptime
  • Api powered updates
  • Optional server icon
  • Optional recent console logs (requires application api key with server.read permissions set in config)
  • Only bot owners may create server status embeds to avoid spam

Server Status Embed

• Node Status Embeds

  • Resource usage (CPU, RAM, Disk)
  • Power state icon and embed color
  • Node name, location, allocations and FQDN
  • Total servers hosted on the node
  • Wings version
  • Api powered updates
  • Only bot owners may create node status embeds to avoid spam

Server Status Embed

✅ Extras

• Autocomplete, Modals & Interaction-Ready

Full support for:

  • Slash commands
  • Autocomplete (server listings, IDs, etc.)
  • Button interactions

• Extended API for more info about your servers

  • Fetch Player counts for game servers that support it (e.g., Minecraft, FiveM)
  • Fetch server version for game servers that support it (e.g., Minecraft, FiveM)
  • More features may be added in the future!

• Flexible API Key System

Supports:

  • Global API key in config for non-user-specific actions (application api)
  • User-specific API keys for personalized server management per user (client api)
  • Synced user permissions with Pterodactyl panel

⚙️ Configuration

  • Setup a Discord bot and get the bot token from the Discord Developer Portal: https://discord.com/developers/applications

  • Rename config.example.json to config.json

  • Fill in the required fields in config.json:

    token: Your Discord bot token
    owner: Your Discord user ID
    client_id: Your Discord bot's client ID
    test_guild_id: Your Discord server ID for testing slash commands
    pterodactyl:
       company: Your Pterodactyl panel's company name
       domain: Your Pterodactyl panel URL (e.g., https://panel.example.com)
       apiKey: Application API key for non-user-specific actions (Only required for node status embeds/panel owner actions)
       API_ENCRYPTION_KEY: A secure random string for encrypting user API keys
       MANAGER_EMBED_UPDATE_INTERVAL: Seconds between resource usage updates in the server manager (uses websockets so discord rate limits are the main concern here)
       SERVER_STATUS_UPDATE_INTERVAL: Seconds between server status embed updates
       SERVER_MANAGER_TIMEOUT: Seconds of inactivity before automatically closing the server manager session/websocket
       ENABLE_SERVER_STATUS_CONSOLE_LOGS: Globally toggle console logs on server status embeds (requires an apiKey with server.read permissions to access wings api)
       NODE_STATUS_UPDATE_INTERVAL: Seconds between node status embed updates
       ERROR_LOGGING_ENABLED: Enable or disable extra error logging to the console for debugging purposes (You probably want this false if you're not a developer or do not have an api key set)
       LOG_HTTP_WARNINGS: Enable or disable warnings when making wings requests over unsecure HTTP connections (leave this on unless you are hosting everything locally and understand the risks of using HTTP)
    
  • ▶️ Invite the Bot to Your Server

    • Use this URL, replacing CLIENT_ID with your bot's client ID:
    • https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=8
  • 🔧 Installation

    • npm install
  • ▶️ Run the Bot

    • npm start
  • 🔗 Link Client Api Key

    • Use the /pt key command to link your personal Pterodactyl API key to your Discord user account if you want to manage your own servers.
  • ⚙️ Manage Your Servers

    • Use the /pt manage command to open the server manager for one of your linked servers!
  • 📝 Create Status Embeds

    • Use the /pt {embed-type}-embed command to create server or node status embeds in your Discord server.
      • Only the bot owner can use this command to avoid spam or misuse.
      • Only one status embed per server or node is allowed to avoid spam.
      • Nodes require an application API key set in the config.
      • Server status embeds only require a user-specific API key assigned with the /pt key command. This means you can create server status embeds for your servers even if you are not the owner of the pterodactyl panel.
      • Server status embeds have two optional parameters:
        • server-icon-url: Include a server icon in the embed if available but leaves less room for other info.
        • console-logs: Shows recent console logs in the embed (requires an application API key with server.read permissions set in the config).

📋 Config Notes

  • domain must end with no trailing slash

  • guildId is only required for local development slash-command registration but is also recommended for single-server bots to speed up command registration.

  • apiKey is required for any node-related actions, including node status embeds. More actions may be added in the future that require this key but their use will likely be intended for panel owners only.

  • MANAGER_EMBED_UPDATE_INTERVAL can be set as low as 1 second if just you or very few others will be using the bot. Higher values are recommended for larger bots to avoid hitting rate limits.

📚 Documentation

  • Offical documentation is not yet available. Please refer to the source code and this readme for guidance.

👤 Author

  • VolumeZero

🤝 Contributing

  • PRs and suggestions are welcome!
  • Issues can be opened any time.

⭐ Show Your Support

  • If this bot helped you or you like it, please give it a star!

📝 License

  • This project is licensed under the MIT License - see the LICENSE file for details.