pterowraptyl
    Preparing search index...

    Class ServersModule

    Module for accessing Pterodactyl servers endpoints. This module provides methods to access server details, create servers, update servers, etc.

    Index

    Constructors

    Methods

    • Creates a new server with the provided data.

      Parameters

      Returns Promise<Server>

      A promise that resolves to the created server.

      const newServer = await app.servers.create({
      name: "My New Server",
      user: 1,
      egg: 5,
      docker_image: "quay.io/pterodactyl/core:java",
      startup: "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
      environment: {
      MINECRAFT_VERSION: "latest",
      SERVER_JARFILE: "server.jar",
      BUILD_NUMBER: "recommended"
      },
      limits: {
      memory: 1024,
      swap: 0,
      disk: 2048,
      io: 500,
      cpu: 100,
      oom_disabled: false
      },
      feature_limits: {
      databases: 2,
      allocations: 1,
      backups: 5
      },
      allocation: {
      default: 1
      }
      });
    • Deletes a server by its ID.

      Parameters

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating success.

      const success = await ptero.servers.deleteServer({ id: 1 });
      console.log(success ? "Server deleted successfully." : "Failed to delete server.");
    • Reinstalls a server by its ID.

      Parameters

      Returns Promise<boolean>

      A promise that resolves to the reinstalled server attributes.

      const success = await ptero.servers.reinstallServer({ id: 1,
      force: true });
    • Suspends a server by its ID.

      Parameters

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating success.

      const success = await ptero.servers.suspendServer({ id: 1 });
      console.log(success ? "Server suspended successfully." : "Failed to suspend server.");
    • Unsuspends a server by its ID.

      Parameters

      Returns Promise<boolean>

      A promise that resolves to a boolean indicating success.

      const success = await ptero.servers.unsuspendServer({ id: 1 });
      console.log(success ? "Server unsuspended successfully." : "Failed to unsuspend server.");
    • Updates a server's build configuration including resource limits and feature limits.

      Parameters

      Returns Promise<ServerAttributes>

      A promise that resolves to the updated server attributes.

      const updatedServer = await ptero.servers.updateServerBuild({
      id: 1,
      allocation: 1,
      memory: 2048,
      swap: 0,
      disk: 4096,
      io: 500,
      cpu: 200,
      feature_limits: {
      databases: 5,
      allocations: 2,
      backups: 10
      }
      });
      console.log(updatedServer);
    • Updates a server's startup configuration including startup command and environment variables.

      Parameters

      Returns Promise<ServerAttributes>

      A promise that resolves to the updated server attributes.

      const updatedServer = await ptero.servers.updateServerStartup({
      id: 1,
      startup: "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
      environment: {
      MINECRAFT_VERSION: "1.19.4",
      SERVER_JARFILE: "server.jar",
      BUILD_TYPE: "recommended"
      },
      egg: 5,
      image: "quay.io/pterodactyl/core:java",
      skip_scripts: false
      });
      console.log(updatedServer);