Typescript starter bot not working ** now working

It seems as though the boilerplate from the Typescript bot doesn’t connect to the runner. I’ve tried to dynamically generate the GUID but my suspicion is the UUID token isn’t getting passed correctly.

Just a heads up . Also any help in getting the bot working would be awesome!

Thanks!

** Here is the code I used to get it working, don’t ask me why, but it works ¯_(ツ)_/¯

import * as signalR from "@microsoft/signalr";
import process from "process";

const runnerIP = process.env.RUNNER_IPV4 ?? "localhost";
const runnerURL = runnerIP.startsWith("http://")
    ? `${runnerIP}:5000/runnerhub`
    : `http://${runnerIP}:5000/runnerhub`;

const botNickname = process.env.BOT_NICKNAME ?? 'BotName';

const token = '762878c9-38e5-4963-9273-9d006ce2626c' ?? process.env.REGISTRATION_TOKEN;

const state = {
    connected: false,
    botId: "",
    botState: null,
};


// Create a connection instance
const connection = new signalR.HubConnectionBuilder()
    .withUrl(runnerURL) // Replace this with the URL of your SignalR hub
    .configureLogging(signalR.LogLevel.Information) // Optional: Configure logging level
    .build();


connection.on("Disconnect", (reason) => {
    console.log("Disconnected with reason: ", reason);
});

connection.on("Registered", (botId) => {
    console.log("Bot registered with ID: ", botId);
    state.botId = botId;
});

connection.on("ReceiveBotState", (botState) => {
    console.log("Received bot state: ", botState);
    state.botState = botState;
});

connection.onclose((error) => {
    console.log("Connection closed with error: ", error);
});

(async () => {
    try {
        // Start the connection
        connection.start()
            .then(() => {
                console.log("Connection established successfully");
                connection.invoke("Register", token, botNickname)
                    .catch((error: Error) => {
                        console.error("Error invoking Register:", error);
                    });
            })
            .catch((error: Error) => {
                console.error("Error establishing connection:", error);
            });
    } catch (ex) {
        console.error("Error connecting: ", ex);
    }
})();

Hey @DSevenster thanks for letting us know!

Soo sorry that you have had to deal with this! We have had a few people complaining about the TS bot. Please be patient with us as we try to resolve the issue :pray:

We want to avoid participants manually adding their own GUID as this is nesserssary for the running of the tournaments for the GUID to be injected via environment variables

We’ll let you know as soon as we have a fix :pray:

@DSevenster it seems like you got it working, please post your solution for others also

Thanks for posting @DSevenster

I’ve moved this Category to Entelect Challenge 2024 | FAQ

Till we find a better fix :blush: