I tried to use the other posts that I’m sure covers my issue but I couldn’t get anything to function. I just want a Nightbot to return a random response from a pastebin but every version of the commands I find on here leads to “Code generation from strings disallowed for this context”. That makes me think it’s something within the pastebin itself, but I couldn’t find anything about it either.
I need a command to just pick one of these to say please ):
My bad, I thought you had a command already. I’ve had an intense migraine these last couple days so I’m sorry if I miss some things. Poking me gently about it like you did is the way to go.
There are two options to fix your code:
• the first one is to keep your JSON in your Pastebin intact and build your code around it:
→ Pastebin:
["pepeMeltdown GO GO GO pepeMeltdown",
"pepeMeltdown GOTTA GO pepeMeltdown",
"pepeMeltdown IM OUTTA HERE pepeMeltdown"]
the error you were receiving was because you were calling a non-raw Pastebin.
you would only have gotten the 2 first options at random: Math.floor(Math.random() * N) gives you a random integer between 0 and N-1,
here satfact.length is equal to 3, so it’ll give you a random number between 0 and 2,
and the first item of an array is always at index 0 and the last one at length - 1.
about the first solution:
you would have had an issue because you put the $(urlfetch) between double quotes " and tried to split it to build an array, when it already is an array.
about the second solution:
you build your array this way when you have a string as input, I replaced the comma with a semicolon since they’re less used.
I tried the first and second option but was met with the same result as before. I tried putting brackets on the pastebin to see if maybe it was that, but had no luck