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 https://api.jokes.one/joke/random)
{
“!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.