Character limit for a custom API

Asked Nov 8, 2021·1 reply·Last activity 4 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.

Hi! Sorry for maybe stupid question. I don't know anything about programming, I just made some code from a bunch of different codes I found on the internet and it worked with a Nightbot. The only problem that I have now - is that the bot only shows 400 characters of the Urban Dictionary definition.
I read, that it's possingle to use json to remove the limit, but I can't modify my code myself.

Here it is:

$(urlfetch https://api.scorpstuff.com/urbandictionary.php?term=$(queryencode $(1:)))

I would be very glad if someone could help!

1 reply

Hey @Trusty Flamingo!

Using the json parameter for the $(urlfetch) only works when you want to pull code or text that's longer than 400 characters, but the output must always be 400 characters maximum.
What I'm gonna do here is crop the output, and I'll also fix your command, because I wonder how it works:

$(eval `$(urlfetch json https://api.scorpstuff.com/urbandictionary.php?term=$(querystring))`.slice(0, 400))

Consider reading the documentation.