Random viewer except like 3 names

I’d like to do a random viewer pull from chat and I currently have this, But is there a way to make it reroll before showing chat to a different name if it pulls nightbot/streamelements for example. This is my current urlfetch $(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))


The random viewer API isn’t set up so that it can choose another viewer if a certain username is picked. Instead you can use this command setup to grab your channel’s viewer list from a remote resource and use $(eval) to filter out certain usernames.

$(eval try{a=JSON.parse(`$(urlfetch json http://tmi.twitch.tv/group/user/$(channel)/chatters)`).chatters;b=a.broadcaster.concat(a.vips,a.moderators,a.staff,a.admins,a.global_mods,a.viewers).filter(c=>![`nightbot`,`streamelements`].some(d=>c.toLowerCase()==d.toLowerCase()));b[Math.floor(Math.random()*b.length)]||`It's lonely in here.`;}catch(e){`Error: ${e.message}`.slice(0,400);})

There is an array of usernames within the code that reads


This is the array of usernames that the $(eval) code will filter from the usernames list. You can add more usernames to be filtered out; just make sure each username is separated by commas and bounded by backticks as shown in the array.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.