In order to know when we are being hosted by another channel we need to peek into the PRIVMSG command when it's delivered by 'jtv' which is a Twitch mechanism that is arguably a little bit old.

In this example we need to parse the message to find out what is happening.'PRIVMSG', function (msg) {
    if (msg.prefix.user !== 'jtv') {

    // "ronni is now hosting you for 0 viewers."
    // "ronni is now auto-hosting you for 0 viewers."
    if (!msg.params[0].includes('hosting you')) {

    const parts = msg.params[0].split(' ');

    const user = parts.shift();
    const viewers = parts.find(part => !isNaN(part));
    const autoHosting = parts.includes('auto-hosting');

    return {
        command: 'hosted',
        viewers: parseInt(viewers, 10) || 0,
});'hosted', function (msg) {
    const { user, viewers, autoHosting } = msg.extended;
    const hosting = autoHosting ? 'auto-hosting' : 'hosting';

    console.log(`${user} is now ${hosting} you for ${viewers} viewers!`);