Connect bot to new channel via function?

Hi all. I have created a bot, that on initialising is able to start following an array of channels. Pretty standard stuff. However, I’m struggling to figure out how I could call a function after the bot has been initiated which would give it a new channel to follow, without having to reboot it. The main issue with rebooting it, of course, is that it then takes time to connect individually to each channel - and of course any function it was running would be stopped.

For reference, I am using twitch.js (similar to tmi.js) - with a fairly standard setup. Is there some function I am missing that can add an extra channel for it to join?

Any help extremely appreciated!

Cheers,
Dan

You mean following or joining the chat to send/receive messages of that channel? Your OP is unclear.

If it’s chat then you just need to use the join command for the library.

Better of checking with the devs of twitch.js as this is a general forum for Developers not the twitch.js support forums

I don’t use twitch.js, but it seems you have to do :

chat.join(channel1).then(channelState => { }) 
chat.join(channel2).then(channelState => { }) 
chat.join(channel3).then(channelState => { }) 

With pureJS and Websocket (=> Like the chatbot.js example) you have to do :

webIRC.prototype.onOpen = function onOpen() {
    const socket = this.webSocket;
    if (socket !== null && socket.readyState === 1) {
        socket.send('CAP REQ :twitch.tv/tags twitch.tv/commands twitch.tv/membership');

        socket.send('PASS ' + this.password);
        socket.send('NICK ' + this.username);
        socket.send('JOIN ' + this.channel);

        [
            "dakotaz", "csgomc_ru", "csgomaincast", "Thijs", "IWillDominate",
            "fextralife", "GSL", "Greekgodx", "CDNThe3rd", "SilverName", "Gosu",
            "stylishnoob4", "ALOHADANCETV", "Solary", "JakenbakeLIVE", "JoshOG",
            "LexVeldhuis", "gammaray_tv", "KingRichard", "Trymacs", "jovirone",
            "BurkeBlack", "Loeya", "just_ns", "GodHunt", "singsing", "fps_shaka",
            "uzra", "Sacriel", "DreadzTV", "DreamLeague", "SovietWomble", "Sick_Nerd",
            "UCCleague", "BreaK", "C_a_k_e", "mandiocaa1", "TidesofTime"
        ].forEach((v) => socket.send(`:{this.username}!{this.username}@{this.username}.tmi.twitch.tv JOIN #${v}`));