Help with a command please

So I’ve got a bit of an interesting request. Essentially I have a nightbot command set up on !quiz to pull a random question from a pastebin. Now what I’m wondering is if it would be possible to have a sort of !answer command that would use something of a numbering system from the questions so when !quiz is used it would give like Question 21… then the !answer 21 could be used seperatly pulling from a formatted pastebin where the answers are numbered respectively to their question. I just am unsure on how to code a command that will use the number to pull from the pastebin. Any help will be appreciated.

Yes that is possible so you would want to make another pastebin with the answers in order of the question number they are assigned to in a format like this:

Answer 1|
Answer 2|
Answer N

You should include a | or some other character in between each entry as long as it is used no where else in the pastebin and the last one will not need one.

The code for the command should look like this:

$(eval a='$(urlfetch json'.split('SEPARATOR');isNaN(`$(1)`)&&$(1)<0?`Please put a question number.`:a[$(1)-1])

This is all assuming I’m understanding the intent of what you want correctly which is to display that answer to a given question number based on the number.

1 Like

Thank you so much works perfectly!!
Just want to let anyone in the potential future know that you cannot have the symbol ’ in the answers even for grammar as it creates an error.

Ah yeah I forgot to mention about qoutes/apostrophe you can add a \ before them to make them not interfere.

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