!slap command with variable outcome

Asked Oct 5, 2020·2 replies·Last activity 5 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.

I already have a !slap command in place where I can get either a user to "slap" or in my case "take aim" at a random or named user, it will then generate my 1st $(eval) which are a list of weapons, I then want it to give me another outcome on a 2nd $(eval) like "and killed them" or "hit the barn door"

The code I have so far is:

$(eval a=[Shot Gun,M4A1,Throwing Knife,Semtex,.50 Cal,Noob Tube];$(user) aimed at ${$(query)||$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))} with a +a[Math.floor(Math.random()*a.length)])!

any help welcomed

2 replies

You could do it all in one eval just set another array of strings like this:

$(eval
a=[`Shot Gun`,`M4A1`,`Throwing Knife`,`Semtex`,`.50 Cal`,`Noob Tube`];
//**
b=[`and killed them`,`and hit the barn door`,`etc.`];
//**
`$(user) aimed at
${`$(query)`?`$(query)`:`$(urlfetch https://2g.be/twitch/randomviewer.php?channel=$(channel))`}
with a
${a[Math.floor(Math.random()*a.length)]}
${b[Math.floor(Math.random()*b.length)]}`)!

The stars aren’t necessary they just indicate where to look