Pick 2 "different" random lines with urlfetch?

Heya all :slight_smile:

I have a timer that gives shoutouts to 2 streamers from my clan every so often. At the moment it just picks a random line from a file twice, but that does sometimes pick the same line twice.

imGlitch imGlitch Why not follow $(eval a=`$(urlfetch json https://zoeballz.tv/nb/REBORN.txt)`.split(`#`);a[Math.floor(Math.random()*a.length)]) and $(eval a=`$(urlfetch json https://zoeballz.tv/nb/REBORN.txt)`.split(`#`);a[Math.floor(Math.random()*a.length)]) who are World of Tanks streamers and members of REBORN :) imGlitch imGlitch

Is there a simple way within the command line to make sure it doesn’t shoutout the same person twice please ? Or do I need to write an API to do it ?
(I don’t know JS !)

Many thanks,

Zoe

It is possible to avoid repeats with JS, using the splice function to remove the first streamer from the list after they have been chosen:

imGlitch imGlitch Why not follow $(eval a=`$(urlfetch json https://zoeballz.tv/nb/REBORN.txt)`.split(`#`);x1=a.splice(Math.floor(Math.random()*a.length), 1)[0];x2=a[Math.floor(Math.random()*a.length)];x1 + " and " + x2) who are World of Tanks streamers and members of REBORN :) imGlitch imGlitch

This also has the advantage of only loading the text file once! Hope it works well for you

2 Likes

Thanks so much :slight_smile:

Seems to run fine :star_struck:

I’ll have to work out JS one day. Still getting to grips with PHP atm !!

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