Unexpected error/ Character limit

I am trying to setup a fun fact command, I have tried for numerous hours and it will not give me any of the facts. I am not sure if it’s the copy and pasted pastebin or if it is something I am doing wrong on the command.

Every variation I try creating the command I get undefined/Unexpected error/Response limit must be under 400 characters or a unexpected token (“split”)

This is the command I am trying to use any help would be appreciated :slight_smile:
$(eval a=$(urlfetch json https://pastebin.com/raw/1xT318F5).split(,);a[Math.floor(Math.random()*a.length)])

Hey @bandithello0!

There are a few issues with your code: first your .split() lacks quotes to know where to cut: split(',') would work, but in your Pastebin you already have an array, so you don’t need to split it, that means you have two options to fix it: either remove the .split(','), or turn the array into multiple lines of text, in which case I suggest changing the separator from a comma , to a vertical line |, so you’d use .split('|')

Have a look here if you choose the second option but can’t see what I mean:

Oh okay, so where every line break is inside pastebin where it ends in a “,” go change it to a bar? Because I see where I was going wrong at. is there a way to have 2 splits or can it only be one so say for an instance “?,” be a end of a split?

where I was going wrong is the forgetting quotations inside the split. but if I must change the pastebin I might wanna get started now but if I can have the 2 inside the “split” would make my day a little faster haha

Thank you for your help :slight_smile:

Okay from taking your advice I changed the .split(’,|’) and now it works absolute perfect. Thank you so much as I was fully stuck on this for almost 2 days… all it took was about 35 mins of editing and it fixed it.

1 Like

Glad you managed to figure it out, but I’ve just checked your Pastebin and you’re going to have issues down the line:

  1. I see you’ve decided to take the route where you remove the array, so you don’t need single quotes marks ' around your facts anymore, unless you want them to show in your chat, it’s up to you
  2. on line 495 you still have a square bracket [
  3. and most importantly, some of your lines end with , | and not ,|, that means your split(',|') won’t match those.

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