code generations from strings disallowed for this context HELP

Asked Aug 6, 2021·5 replies·Last activity 5 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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

5 replies

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)])

Hey @Lively Beaver!

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

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

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.

@Polar Cat 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)])

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

Didn't find your answer? The community is on Discord.

Ask on Discord