Closed JaielZeus closed 5 years ago
(Most likely) same issue with the resub event.
Code:
client.on("resub", (channel, username, months, message, userstate, methods) => {
try {
client.say(opts.channels[0], `Name: ${username}, Months: ${months}`)
} catch (e) { console.log("clientonresub: {0}", e); }
});
Output:
Name: <the actual name of the subscriber>, Months: 0
Server configuration
It's not the same issue as resub (see https://github.com/tmijs/tmi.js/issues/325#issuecomment-460590935).
As far as I can tell, the library is working as intended. You should only get a viewer count when the hosting begins. If the channel is already hosting and then you join, you will probably see "0
" viewers.
https://glitch.com/edit/#!/oasis-mule (Go to "Tool" in the bottom left and choose "Logs")
const tmi = require('tmi.js');
const client = new tmi.Client({ options: { debug: true } });
client.on('unhost', (...args) => console.log('unhost', args));
client.on('hosting', (...args) => console.log('hosting', args));
const hostChannel = 'a';
const targetChannel = 'b';
const parseMsg = require('tmi.js/lib/parser').msg;
client.handleMessage(parseMsg(`:tmi.twitch.tv HOSTTARGET #${hostChannel} :-`));
client.handleMessage(parseMsg(`:tmi.twitch.tv HOSTTARGET #${hostChannel} :${targetChannel} -`));
client.handleMessage(parseMsg(`:tmi.twitch.tv HOSTTARGET #${hostChannel} :${targetChannel} 18`));
[00:41] info: [#a] Exited host mode.
unhost [ '#a', 0 ]
[00:41] info: [#a] Now hosting b for 0 viewer(s).
hosting [ '#a', 'b', 0 ]
[00:41] info: [#a] Now hosting b for 18 viewer(s).
hosting [ '#a', 'b', 18 ]
If you think Twitch is sending bad data, then reopen and I'll ask around.
You can collect raw messages with this:
const tmi = require('tmi.js');
const client = new tmi.client({ /*...*/ });
client.connect();
client.ws.on('message', str => console.log(str));
Actual behaviour: Upon receiving the event that the channel is hosting someone, like when joining the chat or the host starts hosting. The viewer parameter is filled with a 0
Expected behaviour: It shouldn't be 0 viewers. Channel is quite big with 6k, 7k viewers normally. Even when offline there are at least 100, 200 viewers connected to chat.
Logs:
Code
Chat Log
Server configuration