Randomising reply on single command


#1

Ok so I want nightbot to return two queries at random. What I am trying to achieve is, if a question is asked to Nightbot, it replies either yes $(user) or no $(user), with “Nightbot” being the trigger word for the command. I need a way to return either yes or no at random.

If there is usage of a custom api, it would be great if I could be linked to it too!


#2

This command should reply to every message that starts with Nightbot.
!commands add nightbot $(user) $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=yes,no)

A few notes, it will only respond if nightbot is the first word, you can make it respond to @nightbot as well:
!commands add -a=nightbot @nightbot $(query)

The command above will link with an alias to the command I showed first, so you need to have the first one added. Same story, it only works if the message starts with @nightbot.

This command uses an urlfetch url from this topic, which picks a random value from the comma seperated list: Useful Custom APIs


#3

thank you so much! Works great :smiley:


#4

I am also trying to do something similar but have no idea how to achieve this. i would like to add a !funfact command. everytime they type that i would like a random fact to show up but i have been unable to do so.


#5

Heya, a command like this should work:
!commands add !funfact $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=funfact a,funfact b,funfact c)
The random values are comma seperated.

There is a max length of the command field so you might need to shorten the link by using for example bit.ly.

A maybe better solution would be using the Quote system: [CustomAPI] Quote system
Instead of !quote you can name the command !funfact,you can easily add and edit them in your chat instead of having to change the url everytime.


#6

Okay so what i tried was downloading the 3 quote commands. i changed !quote to !funfact and !addquote to !addfunfact. once i did that i redownloaded the 3 quote commands so im at a total of 5 custom commands. i went into my chat and did the !addfunfact and it said successfully added entry #1. but when i did !funfact it says there are no quotes added.


#7

i did this because i would like to have a quote system as well. im not sure if its conflicting or not


#8

It shouldn’t conflict, but it adds 3 commands so make sure you modify all 3 (!quote, !addquote, !delquote).
How did you rename them? Did you use the dashboard? That sounds like pretty strange behavior.


#9

I renamed them !addfunfact !delfunfact !funfact from the dashboard. then i tried to add the facts in my Twitch chat.


#10

I don’t see a reason why it wouldn’t work. You can try doing the manual installation too.


#11

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