Command help with varying inputs

Asked May 7, 2020·2 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.

Hello! I'm trying to essentially modify the !hug command with some special actions to be a !spank command. I have figured out by using some different bits from here how to add an RNG to the command and how to hug specific users... i am guessing what i'm trying to do is doable, but I am not familiar enough with this language to figure it out myself... is there a way to include a typed number and an rng response?

For example !spank nightbot -> "geekmeow spanks nightbot x times" (with random number generated)
but i would ALSO like it to function such that !spank nightbot 4 -> "geekmeow spanks nightbot 4 times"... or whatever number is input there.

I feel like this is somewhat related to how !quote # would work, but I can't figure out how to modify properly to include more than one query, being the username (or whatever is typed after spank) as well as the number. Or maybe I can't, which is fine too. 😛

Currently I have: $(user) bends $(eval a=decodeURIComponent($(querystring))) over their knee and gives them $(eval Math.floor((Math.random() * 100) + 1)) good smacks.

Thank you so much!

stuck_out_tongue.png

2 replies

Hey @Indigo Leopard!

Here's a simple way to do it:

$(eval q=decodeURIComponent(`$(querystring)`).split(` `);q.length==1?n=Math.floor(Math.random()*100)+1:isNaN(q[1])?n=Math.floor(Math.random()*100)+1:n=q[1];`$(user) bends ${q[0]} over their knee and gives them ${n} good smacks.`)
Polar Cat said:
$(eval q=decodeURIComponent($(querystring)).split( );q.length==1?n=Math.floor(Math.random()*100)+1:isNaN(q[1])?n=Math.floor(Math.random()*100)+1:n=q[1];$(user) bends ${q[0]} over their knee and gives them ${n} good smacks.)

thank you so very much! that works perfectly!