To start off, most of this stuff is extremely new to me. So please bare that in mind. I have seen this topic around but can’t seem to get it to work for me from the other topics I have seen.
I am trying to create a Nightbot command that will pull a random ‘fact’ from a list i have made on pastebin. I finally found a code that would for the command but am now running into the issue of [Response must be less than 400 characters] and I have tried to add json to the command like this:
$(eval var frofacts = "$(urlfetch json https://paste…
…as I have seen many other topics state to do this to override the character limit but I can’t seem to get this to work. My code I have currently that worked before the limit is as follows and any help would be much appreciated. Thank you:
$(eval var frofacts = “$(urlfetch https://pastebin.com/raw/AbywSc0x) “.split(”,”); frofacts[Math.floor(Math.random() * (frofacts.length - 1))]
Sorry, that emoji should be a ; and a ) together
Hiya, the code you are using is almost right, including the json part:
$(eval var frofacts = `$(urlfetch json https://pastebin.com/raw/AbywSc0x)`.split(","); frofacts[Math.floor(Math.random() * (frofacts.length - 1))])
The thing you have to watch out for, is that you can’t use certain characters inside your Pastebin. If you use double quotes “” to set the frofacts variable, you can’t use them inside your Pastebin, since the code will think that’s the end of the variable. That’s why I use backticks in my example: ``
The other character you can’t use is the one you use to split the sentences, in your example you use a comma, however in your pastebin you also use comma’s in your sentences, so these sentences will be cut short. You can either remove the comma’s in your pastebin, or use a different character to split the sentences, for example a ;
Thank you so much! It works great now!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.