Random question generator

Hello !

I have been trying to make my own command to pull a random question from this paste bin : https://pastebin.com/raw/tHA0BZ5C

I could be way off what I actually need, but from random forums this is what I’ve thrown together and enter directly into nightbot through the website : $(eval var q = “$(urlfetch https://pastebin.com/raw/tHA0BZ5C)”.split(","); q[Math.floor(Math.random() * (q.length))]:wink:

Please let me know if i have too many spaces, a missing symbol, anything.

It’s telling me I’m going over the 400 character limit despite using the raw link. Super new to this would appreciate any help <33

Hey @didiluvvz!

That’s because the entire content of your Pastebin is treated as one single thing.

How to fix — option #1:
• remove the brackets [] and the backticks ` in your Pastebin
• replace the comma at the end of your options by a character that isn’t susceptible to be inside of one of your option, suggestions: ; ~ # |
• add json as a parameter in your $(urlfetch)

$(eval q='$(urlfetch json https://pastebin.com/raw/XXXXXXXX)'.split('SEPARATOR'); q[Math.floor(Math.random()*q.length)])

where XXXXXXXX is your paste ID, and SEPARATOR is what you have at the end of every options.

How to fix — option #2:
• replace the backticks ` by double quotes " in your Pastebin
• remove the .split() part
• add json as a parameter in your $(urlfetch)

$(eval q='$(urlfetch json https://pastebin.com/raw/XXXXXXXX)'; q[Math.floor(Math.random()*q.length)])

@emily Alright I thiiiiiiink I fixed it, correct me if I’m wrong: also i super duper i appreciate the help

$(eval q=’$(urlfetch json https ://pastebin.com/raw/gZFUpK0)’; q[Math.floor(Math.random()*q.length)])

Thats the final command with my pastebin, added the double quotes. Do I need to remove the brackets still?

Also recognize i could’ve totally misread the quotes and you couke have meant “” and not just “
It’s giving me answers like “R” “r” or “0” through twitch.

Added the space inbetteeen the https so it doesnt get flagged as a link

I can’t see your Pastebin, it’s either deleted or private, either way it won’t work with Nightbot.
Consider creating an account on the website to be able to edit your pastes in the future.

But according to the command you appear to have chosen, you don’t need to remove the brackets [], I would have specified it if it was the case, just replace the backticks ` with double quotes ", so "text" instead of `text`.

Be careful, as these double quotes “text” aren’t the same as "text", the first ones will break the command.

To share your code, format it by adding four spaces in front of it, on a new line, preceded by an empty line.

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