Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClientServerManager

Hierarchy

Index

Constructors

Properties

cache: Dict<string, ClientServer>
client: PteroClient
meta: PaginationMeta = ...

Accessors

  • get FILTERS(): readonly never[]
  • get INCLUDES(): readonly string[]
  • get SORTS(): readonly never[]

Methods

  • _patch(data: any): any
  • Transforms the raw server object(s) into class objects.

    Parameters

    • data: any

      The resolvable server object(s).

    Returns any

    The resolved server object(s).

  • fetch(id: string, options?: { include?: string[] } & FetchOptions & { type?: "admin" | "admin-all" | "owner" }): Promise<ClientServer>
  • fetch(options?: { include?: string[] } & FetchOptions & { type?: "admin" | "admin-all" | "owner" }): Promise<Dict<number, ClientServer>>
  • Fetches a server from the API by its identifier. This will check the cache first unless the force option is specified.

    example
    client.servers.fetch('411d2eb9')
    .then(console.log)
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    • Optional options: { include?: string[] } & FetchOptions & { type?: "admin" | "admin-all" | "owner" }

    Returns Promise<ClientServer>

    The fetched server.

  • Fetches a list of servers from the API with the given options (default is undefined).

    see

    Include and FetchOptions.

    example
    client.servers.fetch({ perPage: 10 })
    .then(console.log)
    .catch(console.error);

    Parameters

    • Optional options: { include?: string[] } & FetchOptions & { type?: "admin" | "admin-all" | "owner" }

    Returns Promise<Dict<number, ClientServer>>

    The fetched servers.

  • Fetches the server resources data of a server.

    example
    client.servers.fetchResources('411d2eb9')
    .then(console.log)
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    Returns Promise<ClientResources>

    The server resources.

  • Fetches the server startup and egg variables data.

    see

    StartupData.

    example
    client.servers.fetchStartup('411d2eb9')
    .then(console.log)
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    Returns Promise<StartupData>

    The startup and egg variable data.

  • getFetchAll<T, K>(...options: unknown[]): Promise<Dict<T, K>>
  • getQueryOptions(): { filters: readonly string[]; includes: readonly string[]; sorts: readonly string[] }
  • Gets the allowed query options from the inherited manager.

    internal

    Returns { filters: readonly string[]; includes: readonly string[]; sorts: readonly string[] }

    The query options.

    • filters: readonly string[]
    • includes: readonly string[]
    • sorts: readonly string[]
  • panelURLFor(id: string): string
  • reinstall(id: string): Promise<void>
  • Triggers the reinstall process of a server.

    example
    client.servers.reinstall('411d2eb9').catch(console.error);
    

    Parameters

    • id: string

      The identifier of the server.

    Returns Promise<void>

  • rename(id: string, name: string): Promise<void>
  • Updates the name of a server.

    example
    client.servers.rename('411d2eb9', 'mc-03')
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    • name: string

      The new server name.

    Returns Promise<void>

  • sendCommand(id: string, command: string): Promise<void>
  • Sends a command to the console of a server. Note that this does not return the output from the command, see WebSocketManager for more information.

    example
    client.servers.sendCommand('411d2eb9', '/say "hello world"')
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    • command: string

      The command to send.

    Returns Promise<void>

  • setDockerImage(id: string, image: string): Promise<void>
  • Updates the docker image of a server.

    example
    client.servers.setDockerImage(
    '411d2eb9',
    'ghcr.io/pterodactyl/yolks:java_17'
    )
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    • image: string

      The docker image.

    Returns Promise<void>

  • setPowerState(id: string, state: "start" | "stop" | "restart" | "kill"): Promise<void>
  • Sets the power state of a server.

    example
    client.servers.setPowerState('411d2eb9', 'start')
    .catch(console.error);

    Parameters

    • id: string

      The identifier of the server.

    • state: "start" | "stop" | "restart" | "kill"

      The power state to set.

    Returns Promise<void>

  • setVariable(id: string, key: string, value: string): Promise<EggVariable>
  • Updates a specified environment variable on a server. The key must be the environment variable name in capital letters, not the normal variable name.

    example
    await client.servers
    .setVariable('b8f32a45', 'SERVER_JARFILE', 'latest.jar')
    .then(console.log);

    Parameters

    • id: string

      The identifier of the server.

    • key: string

      The environment variable key.

    • value: string

      The value of the environment variable.

    Returns Promise<EggVariable>

    The updated egg variable.

Generated using TypeDoc