PixelPlaceJS-new - v3.4.3
    Preparing search index...

    Class Bot

    Pixelplace bot instance.

    Contains helper functions etc.

    Implements

    • Delegate<
          [Protector, UIDManager, Connection, Canvas.Canvas, NetUtil, PixelQueue],
      >
    • DelegateStatic<
          [
              typeof GeometryDrawer,
              typeof LineDrawer,
              typeof TextWriter,
              typeof ImageDrawer,
              typeof Canvas.Canvas,
              typeof NetUtil,
              typeof AnimationDrawer,
          ],
          Bot,
      >
    Index

    Constructors

    Properties

    addToSendQueue: (p: IQueuedPixel) => void

    Internal use only

    boardId: number
    canvasHeight: number

    Height of the current canvas

    canvasWidth: number

    Width of the current canvas

    checkRate: number = -2
    currentBarrier: number = 0

    Current load barrier index

    detectPixels: (pixels: PixelPacket) => void

    Internal use only

    drawImage: (...args: [image: Image]) => Promise

    Draws an image.

    Type Declaration

      • (...args: [image: Image]): Promise
      • Parameters

        • ...args: [image: Image]

        Returns Promise

        A promise that resolves once the image is done drawing, contains place results for all placed pixels.

    drawLine: (...args: [line: Line]) => Promise

    Draws a line between two positions (experimental).

    drawOutline: (...args: [uoutline: Outline]) => Promise

    Draws an outline

    drawRect: (...args: [urect: Rectangle]) => Promise

    Draws a rectangle

    drawText: (...args: [text: TextData]) => Promise

    Draws text.

    Type Declaration

      • (...args: [text: TextData]): Promise
      • Parameters

        • ...args: [text: TextData]

        Returns Promise

        The ending position of the text.

    emit: <T extends keyof PacketSendMap>(
        type: T,
        value?: PacketSendMap[T],
    ) => Promise<void>

    Emits a packet type and value through the socket.

    Type Declaration

      • <T extends keyof PacketSendMap>(
            type: T,
            value?: PacketSendMap[T],
        ): Promise<void>
      • Type Parameters

        Parameters

        • type: T

          Packet type.

        • Optionalvalue: PacketSendMap[T]

          Value. If not set, no value will be sent through other than the packet name.

        Returns Promise<void>

        A promise that will complete once the bot is actively connected; this is usually instant, it only waits if the bot crashes

    getArea: (name: string) => null | IArea

    Type Declaration

      • (name: string): null | IArea
      • Parameters

        • name: string

          The name of the area. E.g. "United States"

        Returns null | IArea

        An IArea instance containing info on the area.

    getAreaById: (id: number) => IArea

    This is used if you want to get the area from a raw packet since the packets give id's rather than names.

    Type Declaration

      • (id: number): IArea
      • Parameters

        • id: number

          The id of an area

        Returns IArea

        An IArea instance containing info on the area.

    getAreas: () => { [key: string]: IArea }

    Type Declaration

      • (): { [key: string]: IArea }
      • Returns { [key: string]: IArea }

        All war locations and stats on them.

    getCanvasData: () => NdArray<Uint16Array<ArrayBufferLike>>

    Returns the canvas data

    getCanvasUrl: (canvasId: number) => string

    Gets the url to a canvas image png;

    This will automatically convert canvas 0 to blank.png as done in pixelplace normally.

    This will also add Date.now() for caching

    getClosestColorId: (r: number, g: number, b: number, _?: number) => null | Color

    Gets the closest color to an r,g,b value

    Type Declaration

      • (r: number, g: number, b: number, _?: number): null | Color
      • Parameters

        • r: number

          red value

        • g: number

          green value

        • b: number

          blue value

        • Optional_: number

        Returns null | Color

        The closest color to rgb

    getColorIds: () => string[]
    getCurrentWarZone: () => string

    Type Declaration

      • (): string
      • Returns string

        The current war zone. Or "NONE" if a war is not found.

    getPaintingData: (
        canvasId: number,
        reload?: boolean,
        connected?: boolean,
    ) => Promise<null | PaintingData>

    Gets painting data

    Type Declaration

      • (
            canvasId: number,
            reload?: boolean,
            connected?: boolean,
        ): Promise<null | PaintingData>
      • Parameters

        • canvasId: number

          The canvas to get painting data of

        • reload: boolean = false

          If it should reload or return the cached value when called again. Defaults to false.

        • connected: boolean = true

          Connected or not. Not too useful. Defaults to true.

        Returns Promise<null | PaintingData>

    getPixelAt: (x: number, y: number) => undefined | Color

    Gets the color of the pixel at x,y coordinates.

    Type Declaration

      • (x: number, y: number): undefined | Color
      • Parameters

        • x: number

          The x coordinate of the pixel.

        • y: number

          The y coordinate of the pixel.

        Returns undefined | Color

        The color of the pixel at x,y.

    getProtectedColor: (x: number, y: number) => undefined | number

    Gets the color being protected at a position, or undefined if not protected

    getRandomColor: () => Color

    Gets a random color

    getRegionAt: (x: number, y: number) => RegionData

    Gets the regional data for a pixel

    This only works on canvas 7.

    Region data has the name, botting status, and repairing status.

    getUniquePlayerId: (
        name: string,
    ) => Promise<`${string}-${string}-${string}-${string}-${string}`>

    Creates a unique player id based on a user's name.

    This utilizes the creation date of the account, which is unique for all players, and converts it into a UUID

    This is deterministic, and the same name will always give the same UUID regardless of session.

    getUserData: (name: string, reload?: boolean) => Promise<null | UserData>

    Gets user data

    Type Declaration

      • (name: string, reload?: boolean): Promise<null | UserData>
      • Parameters

        • name: string

          Name of the user

        • reload: boolean = false

          If it should reload or return the cached value when called again. Defaults to false

        Returns Promise<null | UserData>

    getUsername: (uid: string | number) => Promise<string>

    Gets an account username from the uid. Requires the uid manager enabled.

    Type Declaration

      • (uid: string | number): Promise<string>
      • Parameters

        • uid: string | number

          The uid of the account.

        Returns Promise<string>

        The username from the uid.

    headers: HeadersFunc
    isChatLoaded: () => boolean

    Type Declaration

      • (): boolean
      • Returns boolean

        If the chat is loaded or not. (true/false)

    isConnected: () => boolean

    Type Declaration

      • (): boolean
      • Returns boolean

        If the connection is open

    isPixelInAnyWarZone: (x: number, y: number) => boolean

    This does not account for the current war zone or if a war is occuring.

    Type Declaration

      • (x: number, y: number): boolean
      • Parameters

        • x: number

          X position of pixel

        • y: number

          Y position of pixel

        Returns boolean

        If a pixel is in a war zone (true/false)

    isPixelInWarZone: (name: string, x: number, y: number) => boolean

    This does not account for if a war is occurring. You can check if a pixel is in the current war with isPixelInWarZone(bot.getCurrentWarZone(), x, y)

    Type Declaration

      • (name: string, x: number, y: number): boolean
      • Parameters

        • name: string

          Name of the war zone

        • x: number

          X position of pixel

        • y: number

          Y position of pixel

        Returns boolean

        If a pixel is within a specific war zone.

    isProtected: (x: number, y: number) => boolean

    Type Declaration

      • (x: number, y: number): boolean
      • Parameters

        • x: number
        • y: number

        Returns boolean

        If the spot is protected or not

    isValidColor: (col: unknown) => boolean

    Type Declaration

      • (col: unknown): boolean
      • Parameters

        • col: unknown

          A color id.

        Returns boolean

        If it's a valid color or not.

    isValidPosition: (x: number, y: number) => boolean

    Type Declaration

      • (x: number, y: number): boolean
      • Parameters

        • x: number
        • y: number

        Returns boolean

        if an x,y is on the canvas

    isWarOccurring: () => boolean

    Type Declaration

      • (): boolean
      • Returns boolean

        If a war is occurring (true/false)

    lagAmount: number = 0

    Amount of detected new lag ms; based on pixel confirm response times

    lagIncreasePerMs: number = 1

    Ms to increase pixels when lagging; per lag amount ms

    loadData: LoadData = LoadPresets.DEFAULT

    Current load data

    maxPixelWait: number = 100

    Max time a pixel will be waiting for. Setting place rate will increase this if it's higher.

    netUtil: NetUtil
    on: <T extends keyof PacketResponseMap>(
        packet: T,
        func: (args: PacketResponseMap[T] | Expand<PacketResponseMap[T]>) => void,
        pre?: boolean,
    ) => void

    Enables a listener for a packet. When the packet is received, the function will be called.

    Type Declaration

    params: IBotParams | ServerClient
    placePixel: (upixel: Pixel) => Promise<PlaceResults>

    Places a pixel

    Type Declaration

      • (upixel: Pixel): Promise<PlaceResults>
      • Parameters

        • upixel: Pixel

        Returns Promise<PlaceResults>

        A promise that resolves upon the pixel being sent.

    playAnimation: (...args: [animation: Animation]) => Promise

    Plays an animation. If repeats is -1, it'll play forever and will skip the await. You can then use AnimationDrawer#stop

    premium: boolean = false

    If the bot is premium

    protect: (
        x: number,
        y: number,
        col: null | Color,
        replaceProtection?: boolean,
    ) => void

    Directly protects a pixel. This does not place the pixel down.

    Type Declaration

      • (x: number, y: number, col: null | Color, replaceProtection?: boolean): void
      • Parameters

        • x: number

          The x coordinate of the pixel.

        • y: number

          The y coordinate of the pixel.

        • col: null | Color

          The color of the pixel.

        • replaceProtection: boolean = true

          If it should replace pre-existing protection; defaults to false

        Returns void

    queuedPixels: () => number

    Type Declaration

      • (): number
      • Returns number

        amount of pixels in the sent queue; this is how many are waiting on confirmation

    rate: number = -1

    Shouldn't be edited by the user. This is the rate change packet.

    ratelimited: boolean = false

    If the bot is ratelimited.

    ratelimitTime: number = 0

    Amount of time ratelimited for.

    readQueue: () => readonly IQueuedPixel[]
    send: (
        value:
            | string
            | Buffer<ArrayBufferLike>
            | unknown[]
            | Uint8Array<ArrayBufferLike>,
    ) => Promise<void>

    Sends a value through the socket. It's recommended to use emit() over this.

    Type Declaration

      • (
            value:
                | string
                | Buffer<ArrayBufferLike>
                | unknown[]
                | Uint8Array<ArrayBufferLike>,
        ): Promise<void>
      • Parameters

        • value: string | Buffer<ArrayBufferLike> | unknown[] | Uint8Array<ArrayBufferLike>

          The value to send.

        Returns Promise<void>

        A promise that will complete once the bot is actively connected; this is usually instant, it only waits if the bot crashes

    sendWarPackets: () => void

    This is used internally. Calling this probably won't do anything but I don't recommend it.

    setPlacementSpeed: (
        arg: number | ((prevValue?: number) => number),
        autoFix?: boolean,
        suppress?: boolean,
    ) => void

    Sets the placement speed of the bot

    Type Declaration

      • (
            arg: number | ((prevValue?: number) => number),
            autoFix?: boolean,
            suppress?: boolean,
        ): void
      • Parameters

        • arg: number | ((prevValue?: number) => number)

          Either a direct number or a function for the pixeling

        • autoFix: boolean = true

          If the rate should automatically be updated to be rate_change value -- won't do anything if you use a function

        • suppress: boolean = false

          Suppress warnings if the number is below bot.rate

        Returns void

    sortQueue: (mode: DrawingMode) => void

    Sorts the current queue with a drawing mode

    You can take advantage of this by adding a bunch of pixels into queue with async: false, then sort.

    specialQueueInfo:
        | null
        | { amount: number; start: number; time: number
        | Function } = null

    Special pixel queue info

    stats: IStatistics = ...

    Statistics that are modified internally. Use getStatistics() instead, since it updates other things.

    suppress: boolean = false
    sustainingLoad: number = 0

    Amount of sustained packets

    sysParams: SystemParameters
    uidMan: UIDManager
    unprotect: (x: number, y: number) => void

    Directly unprotects a pixel.

    Type Declaration

      • (x: number, y: number): void
      • Parameters

        • x: number

          X of the pixel

        • y: number

          Y of the pixel

        Returns void

    updateProtection: (protect: boolean, x: number, y: number, col: Color) => void
    userId: number = -1

    The user id of the bot

    username: string = "Guest"

    Username of the bot

    Methods

    • Adds a listener for all sent and received packets

      Parameters

      • settings: IDebuggerOptions = {}

      Returns void

    • Connects the bot to pixelplace.

      Returns Promise<void>

      A promise that will resolve once the socket opens.

    • Gets the connection instance

      This does not verify the bot is connected, you can use await connection.verify(); for that

      Returns Connection

    • Returns number

      Pixeling rate requested by pixelplace

    • Statistics

      Returns IStatistics

      The statistics of the bot.

    • Initiates the bot.

      Returns Promise<void>

      A promise that will resolve once the bot connects and is fully loaded.

    • Loads the bot fully. This should always be ran directly after Connect() or the bot won't function.

      Returns Promise<void>

      A promise that will resolve once the bot is fully loaded.

    • Sets the request headers. This will automatically add the auth cookie.

      Parameters

      • ogFunc: HeadersFunc

      Returns void

    • Parameters

      • data: LoadData

      Returns void