Character Limit

Asked Jan 27, 2024·1 reply·Last activity 2 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, I have a custom API about weather information but whenever i type the command it nightbot replies: [ Response must be less than 400 characters ]. So, I am wondering if its possible to set the amount of characters i want. for an example, I want nightbot to respond the first 200 characters of reply and how do i do that?

That's the command i am using:
!addcom !deneme123 $(urlfetch [http://www.7timer.info/bin/astro.php?lon=113.17&lat=23.09&ac=0&lang=en&unit=m…)]

1 reply

Hey @Burly Deer!

Do you expect the API to respond with text or JSON? Because when I go to the link I get an image.

$(urlfetch) is only to be used for API that respond with text or JSON, it can't deal with images.

If you just want to link to the image, you don't need the $(urlfetch), just put the raw link in the command's message:

!addcom !deneme123 https://www.7timer.info/bin/astro.php?lon=113.17&lat=23.09&ac=0&lang=en&unit=metric&output=internal&tzshift=0

Even though it doesn't apply here, here's how you limit the length of a response from an API to 400 characters:

!addcom !commandName $(eval `$(urlfetch API_LINK)`.slice(0, 400);)