Need api that randomizes viewers/chatters list

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)]:wink: against $(urlfetch$(channel)) and their $(eval const responses = [‘Rock’,‘Paper’, ‘Scissors’]; responses[Math.floor(Math.random() * responses.length)];)!

The “urlfetch” is no longer a valid API. There is a “GET” 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!

1 Like

Do Token Manangement/validation see Getting OAuth Access Tokens | Twitch Developers and Refreshing Access Tokens | Twitch Developers )
Call Get Chatters -
Paginate to all pages of chatters
After collecting everyone into an array pick a random users from the array

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.

The Get Chatters endpoint is the only supported way to get a list of users connected to chat.

1 Like

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

1 Like

have any one solve the problem ?

You need to migrate from the broken API to the Get Chatters API or devise/code/program/create your own solution.

The problem in this post primarily is that someone elses API has broken as it doesn’t support the changes Twitch have made

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

Streamlabs chatbot has the capacity to target a random user if you just want to output a command response.

1 Like

how ??

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