Deprecated: Use of "parent" in callables is deprecated in /var/www/html/forum/src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php on line 431
  • If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

EN ID of the Channel a Client is in

Status
Not open for further replies.

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.
 

Diesmon

Tuetchen Dominator
is awesome!
Contributor
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
 

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:

Diesmon

Tuetchen Dominator
is awesome!
Contributor
Insider
Hm, the code looks allright to me, dunno whats going wrong. :/
 
Status
Not open for further replies.
Top