I’m having a moment over here and can’t figure out how to do a thing. Basically I’m trying to get it so if someone posts “!TrueFacts” or something similar, it’ll respond with a random fact every time. Or, yknow, randomly from a list. Ideas appreciated. Please and Thank you.
This is one way to create that command:
!addcom -cd=5 !truefacts $(eval a=[`fact 1`,`fact 2`,`fact 3`,`etc`];a[Math.random()*a.length])
fact 2, and
fact 3 with your random facts. You can add more facts just as long as each fact is bounded by backticks `` and separated by commas.
However, if you plan on picking from a large list of facts, you may run into trouble as command responses have a 500 character limit on Twitch and a 200 character limit on YouTube.
You can store your facts in a Pastebin file to avoid hitting the limit. Take a look at this paste I wrote to use in a trivia command. Notice how the file starts and ends with square brackets and each fact is bounded by backticks `` and separated by commas. Create a file on Pastebin following the same format, then use this command setup:
!addcom -cd=5 !truefacts $(eval a=$(urlfetch json https://pastebin.com/raw/FOOrBARj);a[Math.floor(Math.random()*a.length)])
Replace the link in the setup with your own Pastebin link. Make sure to use the raw paste link.
I may be doing something wrong. So, I have the command !snakefacts, and used the 2nd command option you gave because it’s going to be a growing list. But I keep getting “Right-hand side of ‘instanceof’ is not an object” when I use the command. Not entirely sure where I went wrong.
$(eval a=$(urlfetch json https://pastebin.com/raw/pHwsYBpF);a[Math.floor(Math.random()*a.length)])
this is what shows in the message section on nightbot’s command edit page.
Look at https://pastebin.com/raw/pHwsYBpF line 5. There is a double backtick `` where there should only be a single backtick `
You are amazing. Thank you SO much! Done and working!