Randomised Answer command?

Hi everyone,

I’m a mod for a Twitch Streamer using Nightbot. We currently have a !funfacts command (with custom facts) which fetches a random option from a Raw PasteBin spreadsheet when the command is used.

Link to where we found the command: Help Randomizing Nightbot Reply in YouTube

This command is great, but the one drawback is that if we want a certain fact to be displayed, we would have to spam the command until it comes up.

Is there a way we could use this command, or a similar command to display a random fact or a certain fact number when it is requested?

Thanks a lot!

Are you asking for a command that allows the user to search up a certain fact using an index number? Maybe using keyword(s)? If so, case-insensitive or case-sensitive search? Do you want Nightbot to return the first fact that contains the keyword? All facts that contain it? One random fact out of all of those that contain it?

Using an Index number, yes.

Say if I put in the command “!Fact22” Nightbot would pull Fact 22 from the list and put it in chat “Fun Fact 22: A pregnant goldfish is called a twit.”

Or something like that.

Edit: make it clearer to understand.

I set up a command called !fact that will output a random fact if there’s no input and output a certain fact if the input has a number index. I also added an error output if the input is not a positive integer smaller than the number of facts in your paste. Copy and paste this into your chat:

!addcom -cd=5 !fact $(eval a=`$(urlfetch json yourFactsRawPasteLink)`.split(`;`);b=decodeURIComponent(`$(querystring)`);if(b==``){a[Math.floor(Math.random()*a.length)];}else{c=parseInt(b)-1;if(c>=0&&c<=a.length-1&&c!=NaN){a[c];}else{`Invalid index!`;}})

Replace yourFactsRawPasteLink with your facts raw Pastebin link!

Hey man, it worked!

I dedicated a fact in your Honour.

Thank you so much!

1 Like

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