How to set up !truefacts command with Nightbot!

I would like to set up a !truefacts command where anyone can use it and the community will receive random facts back! I’m trying to set up 44 commands! Is it doable? Or is it too much words for Nightbot? If doable, how can I set up the command? Please help! Thank you!

Hi please use the search bar:


Thanks a bunch for the help! It was very helpful. Let’s hope I did this right. Haha xD

1 Like

I must have done something wrong. When I try to use the !truefacts command this message pops up: “Unexpected token ':” Please help!

I think I may have figured it out. Please tell me if I am right or wrong. I have my facts written like this [‘Fact #1: MrsPino’s favorite color is pink.’] For all 44! The message said unexpected token ‘:’, Does that mean I have to delete that : ? xD Oh, my!

I took out the : in the PasteBin, but that didn’t change anything. Now I added a syntax highlighting, it didn’t have one before and I went with Json and now this message pops up “Unexpected Identifier”. Please help! I am determined to figure this out. Thank you!

Can you please share your pastebin so I can see where the issue is.

It says I can’t post links! And I tried copy and paste, but the ’ and [ disappear this way :frowning: How may I send you the pastebin?

Thanks again for taking the time to help me. I’m actually doing this for a friend.

Here is my pastebin. I hope this works!

If this helps, here is what I wrote for the !truefacts command:

$(eval a=[urlfetch];a[Math.random()*a.length])

Maybe I’m doing this wrong! Dx It keeps saying “Unexpected Identifier.”

I never managed to make a Pastebin containing an array work, it’s always broken for some reason…
So my fix suggestion is the following, something that proved to work reliably over the years:


Fact #1 Lorem ipsum dolor sit amet, consectetur adipiscing elit.|
Fact #2 Morbi convallis lacinia ipsum.|
Fact #3 Nulla eget metus a nisl lobortis tincidunt.|
Fact #n-1 Maecenas arcu sem, ultricies eu ultricies sit amet, porta non enim.|
Fact #n Vestibulum aliquet justo tellus.

There’s no error, the last one doesn’t end with a | (vertical bar).


$(eval a=`$(urlfetch json`.split(`|`); a[Math.floor(Math.random()*a.length)])

You could even automate the fact-numbering process, just put your facts without the numbers and modify the command like this:


Lorem ipsum dolor sit amet, consectetur adipiscing elit.|
Morbi convallis lacinia ipsum.|
Nulla eget metus a nisl lobortis tincidunt.|
Maecenas arcu sem, ultricies eu ultricies sit amet, porta non enim.|
Vestibulum aliquet justo tellus.


$(eval a=`$(urlfetch json`.split(`|`); r=Math.floor(Math.random()*a.length); `Fact #${r+1} ${a[r]}`)

And if you want to be able to call a specific fact by its number, you can modify the previous command this way:

$(eval q=`$(query)`; a=`$(urlfetch json`.split(`|`); r=Math.floor(Math.random()*a.length); if(q>0 && q<=a.length){r=q-1} `Fact #${r+1} ${a[r]}`)
1 Like

Wow! Thank you so much! These should definitely work now! :slight_smile: Fingers crossed

1 Like

I see that it says urlfetch json before the pastebin link. Is it because you added the json Syntax highlighting? My friend has it on none. Is that okay? Will I have to not add the json? Or it doesn’t matter? Or should I have her add the json syntax highlighting in order for this to work?

The json argument is important, it’s a hack to bypass the 400 characters limit.


Ahhh, so my friend does need to add it then. Wow! You learn something new every day. xD Again thank you so much for taking the time to help me. This really means a lot to me.

1 Like

UPDATE: It worked! Thank you so much for your assistance! I really appreciate your time. :smiley:

1 Like

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