Random Response Help

I’ve made a Random Response for something like the Mystery Box on CoD except it has every weapon they’ve ever released. I don’t know how to actually test it though. I think the code is right but I don’t know where to put the file. It’s just in a .txt document at the moment.
I know there’s something about web hosting but I don’t know anything about that.

Without listing every single gun; here’s what I got;
The url was copied from another topic.

!addcom !box $(user) pulled $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=[“weapon1”,“weapon2”,“weapon3”];a[Math.floor(Math.random() * a.length)])

You go into your Twitch stream (after going in your Nightbot’s Dashboard and making it join the channel) and paste that command start with !addcom. However I think you may be missing some things in the command itself.

Try this:
!addcom !box $(user) pulled $(eval a = $(urlfetch https://api.rtainc.co/twitch/random?format=[0]&choices=["weapon1","weapon2","weapon3"]);a[Math.floor(Math.random() * a.length)])

Thanks, I gave it a shot but no luck. There are over 400 weapons all together, is it just too big to be added in the chatbox?

Oh so that’s the problem you’re having, you want to have the weapons you added in those square brackets be picked at random. I gotcha.
What you should do in that case is store all the possible outcomes in something like a pastebin file, and have the weapon be picked from there. Hang on a sec let me link you to a wonderful response generator that uses Pastebin, put together by @Stoupedog:


Though of course instead of adding jokes to the file, you add weapon names :stuck_out_tongue:

1 Like

Thank you so much for your help! Hopefully I’ll get this done in the next couple of days. :slight_smile:

There is only one problem I found with that wonderful method above and is that there are limits to how many characters total there can be in a pastebin file before Nightbot returns a “Too many characters!” type message.
Create your file with all the possible weapons and put everything together, and if it is the case that you’re reaching the limit once everything is all set and done, post your result here and we’ll move from there :slight_smile:

1 Like

Someone on a Discord server I’m in actually suggested getting filezilla and uploading to a server to be reached by nightbot custom api. I’ll give both a go and hopefully one works. :slight_smile:

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