Used to have commands that randomized the viewers/chatters list in an output, like this one that was made for Nightbot:
!addcom !rpsrandom $(user) dropped $(eval const responses = [‘Rock’, ‘Paper’, ‘Scissors’]; responses[Math.floor(Math.random() * responses.length)] against $(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel)) and their $(eval const responses = [‘Rock’,‘Paper’, ‘Scissors’]; responses[Math.floor(Math.random() * responses.length)];)!
The “urlfetch https://2g.be/twitch/randomviewer.php?” is no longer a valid API. There is a “GET https://api.twitch.tv/helix/chat/chatters” endpoint twitch made available, but I’m not sure how to implement it so that it can work the same way that the previous command did, where users are able to play rock, paper, scissors against each other.
Any ideas or thoughts or possible ways to write this? I’m pretty new to programming so just trying to figure this out. Any assistance is greatly appreciated!
So you’ll need to write some code to seed in a token
And some code to do the actual random selection.
The alternative is your bot asks who wants to play then pick from the people that want to play, then you don’t randomly draw a lurker that doesn’t want to play or are afk
Thank you for providing that! Is there a way of getting or making a custom API for viewers list rather than using the Get chatters endpoint? I don’t think the streamer I’m trying to help would want to go through like tokens and stuff. Like say for instance, you just want to have a command that’s like “user gave ‘random user’ a hug,” is there a way to randomize a viewer list or create a viewer list where we wouldn’t need the get chatters or tokens? Again, I really appreciate you helping me.
I would (like to) assume the channel is running a custom bot.
If so then the custom bot just needs a new oAuth token with the required scopes
And the bot can call the endpoint natively rather than via a urlfetch scenario
The use of urlfetch however sounds like nightbot.
if this is the case then yes you will need to
as it’s required
There never was and continues to not be a way to get viewers.
The dead endpoint was chatters and the new endpoint is chatters.
If you want to grab viewers to
Then you probably want to run an !entry type command to collect people that actually want to play and then pick two people from the entries.
Alternatively this would be a good fit for an extension and take it out of chat altogether
This doesn’t seem to use a token, since theres no sign up flow, and I don’t think you are a mod in every channel and thus is might be in violation of the developer agreement. Since I can’t think of any way this can function without prior permission from the streamer(s).
Or you are collecting and storing a bunch of random data for no reason from a pile of channels.
This seems suspicious, or doesn’t actually pull a viewer/chatter from the chat requested. Or is just gonna break at somepoint due to calling something it shouldn’t