1. The bot currently doesn't work with version 3.1 of the TS client. Please downgrade to an older version. Read this for more information on how to downgrade.

EN ID of the Channel a Client is in

Discussion in 'Script Development' started by vServermean, Nov 23, 2017.

  1. vServermean

    vServermean Member

    Hi i'am prety new to javascript and the Sinusbot scripts.
    So im tinkering around with some coustom scrips for my Sinusbot, wich is working out pretty well.
    My Problem is, i have an event which gets triggert when the bot gets poked, and i want to know the id of the channel the client is in.
    It woud be nice if anybody coud help me out with this Problem, because i coudnt find any soulution jet.
     
  2. Diesmon

    Diesmon Donor is awesome! Insider

    Code:
    event.on('poke', function (ev){
        engine.log('The ID of the channel the client is in who poked me is: ' + ev.client.getAudioChannel().id())
    }
    This should print the Channel ID in the instance log, everytime the bot gets poked
     
  3. vServermean

    vServermean Member

    thx its woking grate, but now i have an other problem :(
    I use backend.getCurrentChannel().id(); to get the ID off the Channel the bot is in. This is working, but only for the first two times i poke the bot. So when i poke the bot the third time the channel id is still the id off the second time poking. In clear words i poke the bot and he joins my channel, i poke him again he goes back to the default channel, i poke him again and nothing happens. And i also tried backend.getBotClient()getAudioChannel()id(); , but i had the same Problem.
    My Code is:
    Code:
        var defaultChannel = '48';
        var currentID;
        var clientID;
    
        event.on('poke', function (ev) {
            clientID = ev.client.getAudioChannel().id();
            currentID = backend.getCurrentChannel().id();
      
            if(currentID == defaultChannel){
                backend.getBotClient().moveTo(clientID);
                engine.log('Coming  [Client/Bot]' + clientID +'/'+ currentID);
            }
            else{
                if(currentID == clientID){
                backend.getBotClient().moveTo(defaultChannel);
                engine.log('Going  [Client/Bot]'+ clientID +'/'+ currentID);
                }
            }
        });
    Log:
    Code:
    2017-11-25T18:44:22+01:00 Could not move: (42 => 48) already member of channel
    2017-11-25T18:44:22+01:00 come :53 Going [Client/Bot]231/231
    2017-11-25T18:44:22+01:00 TS |INFO |ClientUI |1 |Ignored poke by Fugri:
    2017-11-25T18:44:20+01:00 come :53 Going [Client/Bot]231/231
    2017-11-25T18:44:20+01:00 TS |INFO |ClientUI |1 |Ignored poke by Fugri:
    2017-11-25T18:44:18+01:00 come :48 Comming [Client/Bot]231/48
    2017-11-25T18:44:18+01:00 TS |INFO |ClientUI |1 |Ignored poke by Fugri: 
     
    Last edited: Nov 25, 2017
  4. Diesmon

    Diesmon Donor is awesome! Insider

    Hm, the code looks allright to me, dunno whats going wrong. :/
     
  5. vServermean

    vServermean Member

    Ok thx for your help! I made a workaround so i dont need read out the channel of the bot anymore.
     

Share This Page