I have a program that i am writing that gives out a secondary currency to everyone in that chat if certain commands are run and also gives it out over time(similar to the normal currency system). I was wondering: how do you get a list of all current viewers in the chat?
From within PhantomBot, you walk the $.users object, in particular the $.users array which contains slices of user names.
will that only list people who are currently in the chat?
It will show everyone that Twitch has sent a JOIN or PRIVMSG (typed in chat) for. If you read through the Twitch Development forums there is no way to be 100% sure that you get everyone in chat. The IRC USERS command doesn’t promise to return all users, the TMI endpoint is unsupported and has been known to report back empty lists or incorrect lists and is cached and can be off by several minutes (even half an hour). This is why we settled on events from IRC.
So yes, it will contain who is currently in chat as reliably as Twitch provides the data.