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 BaseGameMode.me

      Returns Player

    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

    • 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"
            | "banPlayer"
            | "bootPlayer"
            | "fire"
            | "gameOptions"
            | "goToAmmo"
            | "goToCoop"
            | "goToGrenade"
            | "goToPlayer"
            | "goToSpatula"
            | "lookAt"
            | "lookAtPos"
            | "melee"
            | "move"
            | "reload"
            | "reportPlayer"
            | "resetGame"
            | "saveLoadout"
            | "spawn"
            | "swapWeapon"
            | "switchTeam"
            | "throwGrenade"

      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

    • 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
              | AccountBanned
              | 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

    • 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

      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

    matchmaker?: Socket

    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.

    regionList: Region[] = []

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