Creating commands with ChatGPT

Asked Jan 2, 2023·1 reply·Last activity 3 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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.

1 reply

Hey @Golden Snail!

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.