Hosting Own Channel


#1

Please enable it so that when your channel hosts someone it also displays a message


#2

just make a script with the code below

$.bind('twitchHosted', function(event) {
        var hoster = event.getHoster().toLowerCase(),
            viewers = parseInt(event.getUsers());

        $.say(hoster + ' Has hosted with ' + viewers + ' Viewers');
        return;
});

and

$.bind('twitchAutoHosted', function(event) {
        var hoster = event.getHoster().toLowerCase(),
            viewers = parseInt(event.getUsers());

        $.say(hoster + ' Has auto-hosted with ' + viewers + ' Viewers');
        return;
});

#3

I’ll prefer to embed this into an existing script file. Please suggest which file and which line this code should be placed on?


#4

it would be better as a custom script as if you update you will have to redo it each time


#5

I already do such redos for last few versions in a row. At the same time, I take into account all the changes in the new versions of the bot, of course.


#6

well i would put it in hostHandler.js if anywhere but its so much easyer to make a custom folder and just make the script and place it in there


#7

ok, thank you


#8

How exactly do I create a custom script?


#9

check out a few pages on the forum at custom scripts one being here to see how there set up :slight_smile:


#10

I don’t see a guide on where it goes


#11

Make a custom folder inside the script folder then make a file with any_name_of_your_chose.js and put the code below into it and save then that should do it :slight_smile:

(function() {
    $.bind('twitchHosted', function(event) {
        var hoster = event.getHoster().toLowerCase(),
            viewers = parseInt(event.getUsers());

        $.say(hoster + ' Has hosted with ' + viewers + ' Viewers');
        return;
    });


    $.bind('twitchAutoHosted', function(event) {
        var hoster = event.getHoster().toLowerCase(),
            viewers = parseInt(event.getUsers());

        $.say(hoster + ' Has auto-hosted with ' + viewers + ' Viewers');
        return;
    });
})();

#12

I don’t need to run any command to load it?


#13

Nope it should just do it


#14

oops my bad the code above is for if someone hosts you … for you hosting someone else it would be

(function() {
    $.bind('ircPrivateMessage', function(event) {
        var sender = event.getSender().toLowerCase(),
            message = event.getMessage().toLowerCase();

        if (message.indexOf('hosting') !== -1) {
            var target = String(message).replace(/now hosting /ig, '').replace(/\./ig, '');

            if (target.equalsIgnoreCase('-')) {
                return;
            } else {
                $.discord.say('ChannelNameHere', 'Currently hosting' + target);
            }
        }
    });
})();