Single argument with spaces?

Asked Jan 24, 2020·5 replies·Last activity 6 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.

Hey guys, I'm new here, couldn't find this on search so I hope I'm not repeating a FAQ question.

I want to create a command that accepts one argument, but I need that argument to include spaces (I want to get names of countries as my argument, and some countries have more than one word [e.g: United States, United Kingdom, New Zealand...]).

Is there any way for me to escape that so Nightbot gets that string as one argument with spaces?
Thanks in advance! 🙂

slight_smile.png

5 replies

Nightbot's argument variables depend on spaces to delimit input. Here's a template for setting your own delimiter.

$(eval input = decodeURIComponent(`$(querystring)`).split(`CUSTOM DELIMITER HERE`); // some more code here...)

Cool, thanks! I'll give it a try 🙂

slight_smile.png

Sorry in this case how would you deal? !addcom que haces $(eval Math.random() >= 0.5 ? '$(user)' : '$(touser)') $(eval const responses = ['quien sabe', 'que no ves?', 'si yo no se menos tu CoolStoryBob', 'acabas de llegar?']; responses[Math.floor(Math.random() * responses.length)] 😟

worried.png
!addcom que haces $(eval a=[`quien sabe`,`que no ves?`,`si yo no se menos tu CoolStoryBob`];(Math.random()+0.5?`$(user)`:`$(touser)`)+` `+a[Math.floor(Math.random()*a.length)])

Actually, for my purpose, the $(queryString) was all I needed, as it automatically send the names of the counties encoded so my web-server can easily handle this as one parameter. This is awesome! Works like a charm. Thanks for your help!

Didn't find your answer? The community is on Discord.

Ask on Discord