Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AmongUsSocket

Simple and clean wrapper for making Among Us clients and bots.

If you're reading this through TypeDoc, I highly recommend unchecking "Inherited" in the top right corner. It'll make it so you only have to see the methods and properties that are pertinent to Among JS.

example
import { AmongUsSocket } from '@among-js/sus'
import { PlayerColor, matchmakingServers } from '@among-js/data'

const socket = new AmongUsSocket('testing')
await socket.connect(22023, matchmakingServers.NA[1])
await socket.joinGame('ABCDEF')
await socket.spawn(PlayerColor.Lime)

Hierarchy

  • EventEmitter
    • AmongUsSocket

Index

Constructors

constructor

  • Parameters

    • name: string

      Username to login with

    Returns AmongUsSocket

Properties

isReady

isReady: boolean = false

Whether or not the client is ready to move around and perform actions.

s

The internal Hazel socket. This is exposed in case you want to do things like sending raw packets or disconnecting.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: unique symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

connect

  • connect(port: number, ip: string): Promise<void>
  • Connect to a port and ip address. This also performs a handshake to properly initialize the version and username.

    If you don't know what server to connect to, get an ip from the matchmakingServers export from @among-js/data and use 22023 as a port. You may also want to consider setting up a local Impostor server for testing without putting load on the official servers.

    Parameters

    • port: number

      Port

    • ip: string

      Ip address

    Returns Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

joinGame

  • joinGame(code: string): Promise<Game>
  • Join an Among Us game, and handle join errors as well as redirects. **This only connects! To get an avatar, receive events, and move around you must use the spawn function.`

    Parameters

    • code: string

      Game code to join, as a string

    Returns Promise<Game>

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

move

  • Move to a position with a velocity.

    beta

    Parameters

    • position: Vector2

      Position to move to

    • velocity: Vector2

      Character controller velocity

    Returns Promise<void>

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: "playerMove", cb: (netId: number, position: Vector2, velocity: Vector2) => void): this
  • on(event: "startCounter", cb: (seconds: number) => void): this
  • Parameters

    • event: "playerMove"
    • cb: (netId: number, position: Vector2, velocity: Vector2) => void

    Returns this

  • Parameters

    • event: "startCounter"
    • cb: (seconds: number) => void
        • (seconds: number): void
        • Parameters

          • seconds: number

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

ready

  • ready(): Promise<void>
  • Send a ready packet. This took years to implement so please use carefully.

    Returns Promise<void>

removeAllListeners

  • removeAllListeners(event?: string | symbol): this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this

spawn

  • Spawn the player with an avatar and username, and begin emitting events.

    Parameters

    • color: PlayerColor

      The color to spawn with, from @among-js/data

    Returns Promise<void>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc