Riddle Command 2

Good day.

I have checked on all the post and found 2 x posts for the Riddle command. The problem is that the following does not work :

FOR RIDDLE QUESTION

!addcom -cd=5 -ul=everyone !riddle [ $(user) ] → $(urlfetch json https://nightbot-clip-command.herokuapp.com/riddle )

FOR RIDDLE ANSWER

!addcom -cd=5 -ul=moderator !answer [ $(user) ] → $(urlfetch json https://nightbot-clip-command.herokuapp.com/riddle?q=answer)

Is there someone that have this working that will be willing to share the code for riddle and code for mods to type in for answer.

All your help will be appreciated.
thank you

Hey @killer_virus!

Heroku stopped offering free services, so that may be why the API these commands rely on is dead.

That said, if you found this set of commands, I’m sure you saw our answer on how to make a similar command from scratch: Riddle Command for Nightbot - #10 by Emily


But, I understand you want something a bit different than the command we built there, so here’s how to re-create the command you wanted to use using Nightbot and Pastebin:

First create a Pastebin account so you can go back to your pastes later to edit them, then create a paste following the template below, and save it as “public” or “unlisted”, but not “private.”

[{
  "riddle": "YOUR_FIRST_RIDDLE",
  "answer": "YOUR_FIRST_ANSWER"
},
{
  "riddle": "YOUR_SECOND_RIDDLE",
  "answer": "YOUR_SECOND_ANSWER"
},
// ...
{
  "riddle": "YOUR_LAST_RIDDLE",
  "answer": "YOUR_LAST_ANSWER"
}]

This is JSON, you can make sure you wrote it properly by using a tool like JSON Formatter. (don’t forget to remove // ..., this is a comment, it’s here to suggest that there are more inputs between the second and last riddles)

Now for the commands:

!addcom !riddle $(eval riddles = $(urlfetch json https://pastebin.com/raw/XXXXXXXX); r = Math.floor(Math.random() * riddles.length); `Riddle #${r + 1}: ${riddles[r].riddle}`;)

!addcom !answer $(eval riddles = $(urlfetch json https://pastebin.com/raw/XXXXXXXX); n = parseInt('$(1)') - 1; isNaN('$(1)') ? 'There was an error: only feed the command the riddle\'s ID (without the #)' : (n < 0 || n > riddles.length) ? 'There was an error: this riddle\'s ID doesn\'t exists' : `Answer #${n + 1}: ${riddles[n].answer}`;)

In both commands, replace XXXXXXXX with the paste ID, which you’ll find in the URL once created.
If you want to make the !answer command mod-only, add -ul=mod between !answer and $(eval).

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