Alternative command

I am using this to get a random choice from a pastebin list and its working great:

$(user) Chose: $(user) $(eval $(urlfetch json https://pastebin.com/raw/PRrACDy1))

example pastebin:

a=[

**Gator Rush Introduction, **
**Gold Rush, **
**Lake Michigan, **
**Glacier Park SquadX Event, **
**Glacier Park Tiger Tonic Event, **
**Lake Michigan by Night, **
**Gator Rush Main Event, **
**Glacier Park, **
**Bayou, **
Lake Michigan Endurfix Event

];a[Math.floor(Math.random() * a.length)]

I have multiple commands to pull from the associated lists.

Is it possible to create a command that would pull one random list item from all lists?

Hey @BullDog_7!

Yes, and given how your Pastebins are set, you would go like this for example:

$(eval $(urlfetch json RAW_PASTEBIN_LINK_A); $(urlfetch json RAW_PASTEBIN_LINK_B); $(urlfetch json RAW_PASTEBIN_LINK_C); `${a} ${b} ${c}`)

Assuming your first Pastebin uses a, the second uses b, the third c, etc.

thank you I’ll give it shot tonight

So the every raw link needs to be used twice if I read that correctly?

I see what you meant. I guess I need to clarify. I have multiple pastes including individual lists. What I want is a single result, randomly picked from multiple pastes if possible.

I see… Then I’d go like this:

$(eval $(urlfetch json RAW_PASTEBIN_LINK_A); $(urlfetch json RAW_PASTEBIN_LINK_B); $(urlfetch json RAW_PASTEBIN_LINK_C); r=[a,b,c]; r[Math.floor(Math.random()*r.length)])

Still assuming your first Pastebin uses a , the second uses b , the third c , etc.

Thank you but I dont understand this part:

r=[a,b,c];

in reference to my links

Your first Pastebin link must use the variable a, your second one must use the variable b, the third one must use the variable c, etc…
r=[a,b,c] combines all the random outputs from your various pastes, and then we pick a random output out of these.
If you have more than 3 pastes, add d, e, etc.
I can’t be clearer than this.


If you still don’t understand, we’ll do it my way, I tried to adapt my code to your pastes, but you’re going to have to update your pastes to reflect my code, just so we get a clean and clear code.

Your Pastebin should look like this, nothing more:

`(HC) - New York`, 
`(HC) - Detroit`, 
`(HC) - Bronx`, 
`(HC) - Hollywood`, 
`(HC) - The Road to New Orleans`, 
`(HC) - Sights on Sin City`, 
`(HC) - Highspeed Takedown`, 
`(HC) - Los Angeles`, 
`(HC) - Latrells Car Part 1`, 
`(HC) - Latrells Car Part 2`, 
`(HC) - White Rock Hills`, 
`(HC) - Maine Highlands East`,
`(HC) - South Trip`,
`(HC) - Big Land`,
`(HC) - Going to Vegas`,
`(HC) - Dallas`

Then the code is the following:

$(eval 
a=$(urlfetch json FIRST_RAW_PASTEBIN_LINK).split(`,`);
b=$(urlfetch json SECOND_RAW_PASTEBIN_LINK).split(`,`);
...
n=$(urlfetch json N_RAW PASTEBIN_LINK).split(`,`);
z=a.concat(b,...,n);
z[Math.floor(Math.random()*z.length)];
)

So if you have 4 pastes:

$(eval 
a=$(urlfetch json FIRST_RAW_PASTEBIN_LINK).split(`,`);
b=$(urlfetch json SECOND_RAW_PASTEBIN_LINK).split(`,`);
c=$(urlfetch json THIRD_RAW_PASTEBIN_LINK).split(`,`);
d=$(urlfetch json FOURTH_RAW_PASTEBIN_LINK).split(`,`);
z=a.concat(b,c,d);
z[Math.floor(Math.random()*z.length)];
)

Another solution would be to create a new paste where you combine them all and just get a random output from there.

Thank you so much, thats much cleaner. I’ll try it out soon!

1 Like

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