code generations from strings disallowed for this context HELP

So, i was following a tutorial about random messages, a very recent one, made by unknownemerald on ytb, and he used the folllowing code to create the command

$(user), $(eval a="$(urlfetch json https://pastebin.com/raw/YOURCODE)".split(";");a[Math.floor(Math.random()*a.length)])

but when I mae my own code all i get is this error message.

help please

Hiya, what error message are you getting?

This should work:

$(user), $(eval a=$(urlfetch json https://pastebin.com/raw/XXXXX).split(";");a[Math.floor(Math.random()*a.length)])
1 Like

Hey @fran_cee!

It would also be easier to help you if we knew what is the code in your paste.

1 Like

I was getting the error message on the tittle (code genration from strings disallowed for ths context)

with this code you gave (which uses a raw option from pastebin) I am getting yet another error, it says "unexpected token “;” ".

I realized now I should have used a raw option in my first attempt, I’m clearly pretty dumb in regards to all sorts of codings, but I still don’t know how to fix this current error.

my code is just a test code, as folllows:

  1. Test.;

  2. Test2;

tried with and without numbers. got slightly different erros, unexpected token and unexpected indetifier.

@Emily too, thanks!

If you’re gonna put different responses in the Pastebin, here’s how to do it:

RESPONSE_1;
RESPONSE_2;
...
RESPONSE_N

No numbers unless you want them in the responses, and the last response shouldn’t end with a semicolon.

Also xgerhard forgot to put the $(urlfetch) between quotation marks, although it would have been correct if the content of your Pastebin was actually JS code (you wouldn’t want to split with the semicolon in that case btw) instead of just various text responses:

$(user), $(eval a='$(urlfetch json https://pastebin.com/raw/XXXXX)'.split(';');a[Math.floor(Math.random()*a.length)])
1 Like

So, I ended up forgetting to stop by and say you guys fixed my issues! everything is running perfectly, thanks!

1 Like

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