yolkbot
    Preparing search index...

    Class Bot

    A Bot! The big big amazing class the world revolves around

    Index

    Accessors

    • get me(): Player

      The current bot's player, if it's initialized. Be careful with this and read the warning in Game.me

      Returns Player

    • get players(): (Player | undefined)[]

      The players, refers to the players field in any game class (Game.players)

      Returns (Player | undefined)[]

    Constructors

    • Creates a bot with the parameters. None of them are required, some more recommended than others!

      Parameters

      • params: Partial<BotParams> = {}

        The parameters for the bot

      Returns Bot

    Methods

    • Creates an account with the given email and password and adds it to the current bot

      Parameters

      • email: string

        The email

      • pass: string

        The password

      Returns Promise<LoginResponse>

      The result of the login attempt, including the account if it succeeded

    • Connects to the matchmaker for the first time and establishes automatic reconnection

      Returns Promise<{ ok: true; regionList: Region[] } | ErrorEnum<MatchmakerError>>

      The result of the connection attempt, including the region list if it succeeded

    • Dispatches

      Type Parameters

      Parameters

      • dispatch: D

        The dispatch to send out

      Returns boolean

      Whether the dispatch's initial parameter validation check succeeded; it does NOT contain anything about the results of the constant check that runs in the background

    • Disposes a bot instance by clearing timeouts, leaving games, and disconnecting from the matchmaker

      Returns void

    • The easier way to dispatch something.

      Type Parameters

      • E extends
            | "pause"
            | "chat"
            | "gameOptions"
            | "banPlayer"
            | "bootPlayer"
            | "melee"
            | "reload"
            | "reportPlayer"
            | "saveLoadout"
            | "swapWeapon"
            | "switchTeam"
            | "throwGrenade"
            | "fire"
            | "goToAmmo"
            | "goToCoop"
            | "goToGrenade"
            | "goToPlayer"
            | "goToSpatula"
            | "lookAt"
            | "lookAtPos"
            | "move"
            | "resetGame"
            | "spawn"

      Parameters

      • eventName: E

        The event name. You can see a list in the "properties" of DispatchIndex

      • ...args: DispatchParams[E]

        The arguments you can pass. You can find the file link in DispatchIndex and then look at the constructor of the dispatch class to see what arguments it takes.

      Returns void

    • Checks if a hook is attached to the bot

      Type Parameters

      Parameters

      • event: K

        The name of the event

      Returns boolean

      Whether any hook is attached for that event

    • Ensures the bot is in game; best used with Typescript

      Returns this is BotWithGame

    • Initializes the session for the by logging in (if not already) and connecting to the matchmaker (if not already). This is required before finding, creating, or joining a game and is called automatically if you fail to do so

      Returns Promise<
          | { ok: true }
          | ErrorEnum<
              FirebaseError
              | QueryServicesError
              | LoginError
              | MatchmakerError,
          >,
      >

      Whether the initialization succeeded or the error that caused it to fail

    • Logs into an existing account with the given email and password and adds it to the current bot

      Parameters

      • email: string

        The email

      • pass: string

        The password

      Returns Promise<LoginResponse>

      The result of the login attempt, including the account if it succeeded

    • Logs in anonymously, which is the recommended way to do a quick login without needing to create an account. You can save these if absolutely needed by saving the Account.firebase's refreshToken and using Bot.loginWithRefreshToken

      Returns Promise<LoginResponse>

      The result of the login attempt, including the account if it succeeded

    • Logs in using Google (works only on Node and non-headless environments)

      Parameters

      • OptionalrequiredEmail: string

      Returns Promise<LoginResponse>

      The result of the login attempt, including the account if it succeeded

    • Removes a specific callback hook for a specific event

      Type Parameters

      Parameters

      • eventName: K

        The name of the event to stop listening for

      • Optionalcallback: (...args: BotEvents[K]) => void

        The specific callback to remove; if not provided, all hooks for the event will be removed

      Returns void

    • Registers a callback for a specific event. All events are viewable at BotEvents

      Type Parameters

      Parameters

      • eventName: K

        The name of the event to listen for

      • callback: (...args: BotEvents[K]) => void

        The callback to run when the event is emitted, with the parameters for that event as arguments

      Returns void

    • Regisers a global callback for any hooks. This is incredibly resource-intensive and shouldn't be used aside from development (things like finding hook names), as it means that some hooks (such as BotEvents.packet) run intensive data computations that aren't normally performed unless needed.

      Parameters

      • callback: <K extends keyof BotEvents>(event: K, ...args: BotEvents[K]) => void

        The callback to run on any event. The first parameter is the event name and the rest are the parameters for that event

      Returns void

    Properties

    account?: Account

    The bot's account, if it has one

    firebase: Firebase

    An associated firebase instance

    game?: AnyGame

    The bot's game, if it's in one

    instance: string = 'shellshock.io'

    The game instance attached to the bot.

    matchmaker?: WSSocket

    The matchmaker socket, if it's connected to the matchmaker (Bot.createMatchmaker)

    matchmakerListeners: ((...args: any[]) => void)[] = []

    Listeners for messages from the matchmaker, requires you to call Bot.createMatchmaker first

    packetHandlers: Partial<Record<number, (...args: any[]) => any>> = ...

    Allows you to override the handlers for specific packets.

    protocol: string = 'wss'

    The instance protocol attached to the bot.

    proxy: string = ''

    The proxy the bot uses to connect to games.

    regionList: Region[] = []

    The region list the bot has found, requires you to call Bot.createMatchmaker first

    renewSession: boolean = false

    The session renewal