Permission denied when using host command with tmi.js library

I’m working on a bot using the tmi.js library and running into a permissions problem. When I try to host another channel, I keep getting an error message.

Here’s what I’m trying to do:

botClient.say(`#${myChannel}`, `/host streamername`);

Or using the dedicated method:

botClient.host(`#${myChannel}`, `streamername`).then(function(result) {
    console.log(result);
}).catch(function(error) {
    console.log(error.toString());
});

But I always get this error:

info: [#<mychannel>] You don't have permission to perform that action.

Other commands work fine like sending regular messages:

botClient.say(`#${myChannel}`, 'Hello everyone');

I’m the channel owner and I’m using my own username and OAuth token for authentication. The connection works and I can send normal chat messages without any issues. What could be causing this permission error when trying to host?

I ran into this exact problem when I started using tmi.js for my channel bot. The issue isn’t your OAuth scopes - Twitch killed the host command completely back in October 2022. Even with perfect auth and permissions, /host just doesn’t work anymore. This breaks both the chat command method and tmi.js’s dedicated host function. The library kept the host function so old code wouldn’t break, but Twitch’s API ignores these requests now. You’ll need to switch to something else like raid functionality, which still works and does basically the same thing for sending viewers to other channels.

ya, sounds like ur oauth token might be missing the right scopes. def make sure u got the channel:editor one set up when u created it. that’s what trips up those host commands sometimes, even if chat works!