Creating commands with ChatGPT

For instance I am trying to get the !joke command to generate a random joke but the website has formatting.

!joke returns {“type”:“general”,“setup”:“Why are mummys scared of vacation?”,“punchline”:“They’re afraid to unwind.”,“id”:307}

So I asked GPT to remove the formatting it gave me this:

!addcom !joke $(urlfetch
“!joke”: “$(eval
var data = JSON.parse(response.body);
if (data.type == “general”) {
return data.setup + “\n” + data.punchline;

Which gives me Remote Server Returned Code 401 { “!joke”: “Illegal return statement” }

I know ChatGPT isn’t perfect at generating code but I thought I’d try to understand what is going wrong here and how to make it return better code for nightbot.

Hey @mrallgamesallday!

This endpoint of this API requires you to pay, you need to send a secret via cURL for it to respond, but Nightbot doesn’t handle cURL requests as far as I know, therefore you’ll always get a 401.

1 Like

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