NightDev Community Forums

Randomly fetch multiple items from a list without duplicates

Hi, there.
Im trying to make a command that fetches 8 items from my list but it only return one response. How can i make it return 6 from my url.

Heres the command

$(user) just found $(eval var V = $(urlfetch json https://pastebin.com/raw/XXXXXXXX).split(","); V[Math.floor(Math.random() * (V.length = 6))]:wink:

Any help is apreciatted, thank you.

For multiple responses use

$(urlfetch https://vxrl.xyz/smm/message1/message2/message3/message4/message5/message6?i=5000&d=1)

Edit: ignore my spelling of “message”

1 Like

Hi there, thank you so much for your response.
i have a list of 500 or more items written like this
"
spin,
dash,
axe,
crayon,
sans,
pic
"
Your command seems to work fine however i dont think i can write all 500 items inside the command that you gave me. How can i make a command that withdraws 6 or 9 random items from my list in a single response and not 6 responses?

$(user) just found $(eval var V = $(urlfetch json https://pastebin.com/raw/XXXXXXXX).split(","); V[Math.floor(Math.random() * (V.length = 6))]:wink:

This command that i had works fine but it only gives me back one item… and i,d like to call back 6 or more.

Any help is apreciatted, thank you.

Hey @zombienoob!

Here’s the solution you’re looking for:

$(eval a=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`.split(`,`); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} `$(user) just found: ${b.join(`, `)}.`)

Notes:
• if you want to extract more than 6 items from the list, change the number in the for() loop: for(i=0;i<6;i++)
• I included a.pop(); thinking that your last item also ends with a comma, if that’s not the case, remove it from the code.

2 Likes

Hi there @EmilyPerrimon thank you so much for your response.
I replaced the xxx with my link but it gives a Unexpected template string?

Not sure why it doesnt work :sneezing_face:

$(eval a=`$(urlfetch json https://pastebin.com/raw/j4zpB2rM)`.split(`,`); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} `$(user) just found: ${b.join(`, `).`)

Btw ill be updating that list with a bunch o nerdy stuff xD

@zombienoob Heya, this will work… Tested

$(eval x =$(urlfetch json https://pastebin.com/raw/XXXXXX).split(,); x.pop(); t=[]; for(i=0;i<6;i++){t.push(x.splice(Math.floor(Math.random()*x.length),1));} "$(user) just found: " + t.join(’, ') + “.”)

1 Like

The error lies in your Pastebin: remove the first and last " (quotation marks) and it’ll work.

1 Like

Hey guys @EmilyPerrimon @Ritik_Ranjan, thank you for your responses to this post. As far as i,ve tested noone of the new commands work. I,ve spend hours testing to see if anything at all works but it doesnt… I decided to follow your instructions and make a pastebin without any quotations but the command turn into identifier missing or unexpected.
Resuming my many tests regarding this post, it goes as follows

I copied the commands that you guys gave and just replace the my pastebin, but unfortunately nothing is working…

My link with quotation marks: Unexpected template string

$(eval a=$(urlfetch json https://pastebin.com/raw/j4zpB2rM).split(,); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} $(user) just found: ${b.join(, ).)

Then i removed the quotations as suggested, in this link: Unexpected template string

$(eval a=$(urlfetch json https://pastebin.com/raw/L4YJ7qJb).split(,); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} $(user) just found: ${b.join(, ).)

Then i tested my luck with this: Unexpected identifier

$(eval a=$(urlfetch json https://pastebin.com/raw/p6euakP8).split(,); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} $(user) just found: ${b.join(, ).)

Somewhat this gave a response but not any items and it made like a happy face?: : ).

$(eval a=$(urlfetch json https://pastebin.com/raw/j4zpB2rM).split(,); a.pop(); b=[]; for(i=0;i<6;i++){b.push(a.splice(Math.floor(Math.random()*a.length),1));} $(user) just found: +b.join(, ).)

Then i tested the other response as follows…

I tested the first link with quotation marks: Unexpected token ‘,’

$(eval x =$(urlfetch json https://pastebin.com/raw/j4zpB2rM).split(,); x.pop(); t=[]; for(i=0;i<6;i++){t.push(x.splice(Math.floor(Math.random()*x.length),1));} "$(user) just found: " + t.join(’, ') + “.”)

And also when i tested the link without quotations marks: Unexpected token ‘,’

$(eval x =$(urlfetch json https://pastebin.com/raw/L4YJ7qJb).split(,); x.pop(); t=[]; for(i=0;i<6;i++){t.push(x.splice(Math.floor(Math.random()*x.length),1));} "$(user) just found: " + t.join(’, ') + “.”)

Finally i tested my links with my original command to see if maybe something was wrong with them and they work fine, except they dont return the multiple items…

$(user) just found $(eval var V = $(urlfetch json https://pastebin.com/raw/j4zpB2rM).split(","); V[Math.floor(Math.random() * (V.length ))]:wink:

$(user) just found $(eval var V = $(urlfetch json https://pastebin.com/raw/p6euakP8).split(,); V[Math.floor(Math.random() * (V.length ))]:wink:

Anyways not sure why the new commands dont work…

3 Likes

Thank you for the lengthy explanation of your tests, and I found the issue with my command, it’s my bad, I forgot a bracket… I keep forgetting these lately, I have to be more careful, I was sure I verified many times though. Anyway, I updated my first reply, use the Pastebin without the quotation marks.

1 Like

Omgoshhh it finally worked thank you so much @EmilyPerrimon!! Now ill be updating that list. Thank you again and warm hugs everyone :hugs:

1 Like