NightDev Community Forums

Character Limit! D:

Hello!

So I’m writing a few different commands that randomize the responses from a list, similar to the 8ball command, using javascript Math.random. The problem is there’s a character limit on the message, both when adding the commands through the chat and also on the Nightbot backend. Even with short responses, the character limit limits the number of possible responses. Is there a way around this? Thanks for any help! :smiley:

You could use Pastebin to store the random responses, example here: Response Generator

If all of your responses take up more than 400 characters, you will have to use $(urlfetch json ...) instead of $(urlfetch ...). This is because the normal $(urlfetch ...) will only download up to 400 characters.

If you’re using $(urlfetch json ...), the list needs to begin and end with a ". You also need to pick a character to separate each response, such as ,.

Here’s a command for getting a random response from https://pastebin.com/raw/TpLfyurA which uses , as its separator:

$(eval responses = $(urlfetch json https://pastebin.com/raw/TpLfyurA).split(","); responses[Math.floor(Math.random() * responses.length)])
1 Like

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