Hi! I’m a mod trying to add a random fact command to chat and I’ve searched through quite a few topics here trying to fix the issue I’m having with Nightbot in an attempt to create a random fact command. When I attempt to use it, I’m getting back the message ‘Unexpected identifier’. I originally had backticks and commas in my pastebin from the first post I came across and thought maybe that was it so I removed those and added ;. I then switched from ; to |. I’ve used the following:
!addcom -cd=5 !truefacts $(eval a=$(urlfetch json https://pastebin.com/raw/Wa8xp70R);a[Math.floor(Math.random()*a.length)])
!addcom -cd=5 !squidfacts $(eval a=`$(urlfetch json https://pastebin.com/raw/Wa8xp70R)`.split(`|`); a[Math.floor(Math.random()*a.length)])
!addcom -cd=5 !squidfacts $(eval facts= "$(urlfetch json https://pastebin.com/raw/Wa8xp70R)".split(";"); facts[Math.floor(Math.random() * (facts.length - 1))])
This last one I did not use after switching to |. Would the " vs ’ in split change anything because of my use of single ’ in my facts? I’m genuinely a fish out of water when it comes to a lot of coding.
Thank you for any help you can provide!