Game.players always empty Object

import dotenv from "dotenv";
import { Game } from "@gathertown/gather-game-client";
import webSocket from "isomorphic-ws";
dotenv.config();
global.WebSocket = webSocket;

const API_KEY = process.env.GATHER_API_KEY;
const GATHER_SPACE =  process.env.GATHER_SPACE;

const onConnected = (connected) => {
    console.log("Connected: ", connected);
    game.enter(GATHER_SPACE);
    console.log(Object.keys(game.players))
    console.log(game.getStats())
}

const game = new Game(() => Promise.resolve({ apiKey: API_KEY }));
game.connect(GATHER_SPACE);
game.subscribeToConnection(onConnected);
game.subscribeToEvent("playerJoined", (player) => {
    console.log("playerJoined", player);
    console.log(Object.keys(game.players))

});

With the above code game.players is always empty, and the event playerJoined is never emitted I tried on two separate spaces I get the same results.

The Event is "playerJoins", not "playerJoined". Otherwise it should work.

Yeah, now it seems to work, I get the correct list, very curios why Github Copilot autocompleted with Joined instead of Joins.

Just finding this, since Bill helped out :slight_smile:

I would recommend using TypeScript here where possible - our library comes with strict typing and subscribeToEvent has a union on it that will stop your code from compiling if you accidentally enter the wrong one. Also, if you haven’t seen our docs, here: