# Maximum command length/any better way of randomisation?

I’ve got a problem. I tried to make universal random command, which would get a random one of five or less arguments. I made a script already (not tested yet), tried to add this command in my channel for test, but there was a big problem: max command length is only 250. Is there a way to make the max length bigger, or anything like this? Probably no, but it’s always worth trying.
But I’ve got an idea. I’ll give you a script and You can take it, if u want, but please, if someone would know how to make it shorter (i think it’s possible, but i don’t know how) or see any mistakes, please tell me how or send the repaired version of script.

var w1 = ‘\$(1)’;w2 = ‘\$(2)’;w3 = ‘\$(3)’;w4 = ‘\$(4)’;w5 = ‘\$(5)’; if (w5 != ‘’) {const responses = [’\$(1)’, ‘\$(2)’, ‘\$(3)’, ‘\$(4)’, ‘\$(5)’]; responses[Math.floor(Math.random() responses.length)];} else {if (w4 != ‘’) {const responses = [’\$(1)’, ‘\$(2)’, ‘\$(3)’, ‘\$(4)’]; responses[Math.floor(Math.random() responses.length)];} else {if (w3 != ‘’) {const responses = [’\$(1)’, ‘\$(2)’, ‘\$(3)’]; responses[Math.floor(Math.random() responses.length)];)} else {if (w2 != ‘’) const responses = [’\$(1)’, ‘\$(2)’]; responses[Math.floor(Math.random() responses.length)];)} else {‘Enter more arguments.’;};};}

PS: JavaScript syntax is sick!

If you enter the command through Nightbot dashboard the max length will be 500.

About the script, you might just want to explain what you are trying to do so someone can maybe help you out with a shorter version.

This can be made using `\$(query)` instead of `\$(1-9)`. You can do something like this instead:

`!commands add !ran \$(eval const q = `\$(query)`.split(' '); q.length > 1 ? q[Math.floor(Math.random()*q.length)] : 'Please add more than one argument')`

1 Like