Hello! I'm working on a command that posts a random line of text from a video game. In that game, you can name your own character, so I thought it would be fun if I could use the dialogue including the player's name, and replace that with the user who called the command. I did some searching, and this thread: /t/nightbot-command-with-pastebin-tagging-a-user/1534640086879178874#m1534640… was the closest to what I'm trying to do.
I adapted it to my situation (I'm only working with one variable, and that thread has two), and did some testing on a simple paste with only lines which contain the $(user) variable, represented as "${u}", and it worked! However, when I try the command on my entire document, I get a "[Response must be less than 400 characters]" error.
I was kind of agonizing over this for a while, trying different stuff. But I think the issue is that the command is expecting to find a user variable in every result? If my document has one on every line, it works; if not, it doesn't.
This is what my code is looking like right now (I'm using github gists instead of pastebin because pastebin called my text "explicit" or something):
$(eval u=`$(user)`; p=`$(urlfetch https://gist.githubusercontent.com/webcamcals/78ee5273639b0cc5e72c4559b0d8f64d/raw/006d6e9d70f75e697bd31fefe5e12956714155a6/crystal)`.split(`#`); p[Math.floor(Math.random()*p.length)])
If I'm right about what's causing the issue (I could easily be wrong, I'm not a programmer 😛), is there a way to fix this so that it will parse variables when relevant, but not break if there isn't one on every line? Thanks!