Multiple random evals?

Asked Oct 7, 2020·5 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.

So I am trying to make a !slap command. I want it to read as follows. User slaps user with weapon and it was (randomeffectiveness)

I have the first part working fine. it picks a random weapon and life is great.

its part 2 (the random effectivness) that im struggling with.

Current command:
$(user) has slapped $(touser) $(eval var weapon=["with a cactus.","with a frying pan.","with a brick.","with common sense.","with heavy sarcasm.","with a raw fish?"]; weapon[Math.floor(Math.random()*weapon.length)];) $(eval a=[“It was super effective!”,“It was not very effective.”,”It does not affect $(touser).”]; a[Math.floor(Math.random()*a.length)];)

Also those emojis should not be there. Its supposed to be a semicolon followed by a )

5 replies

Uhm is it outputting an error for the second part of the command at all? Cause I don’t seen anything wrong with the second eval that would make it not work.

Yea it says string not found, or invalid.

Wyn has slapped @member with a raw fish? Invalid or unexpected token

i tried removing the touser and it still isnt working. Same thing as before. First half works, second half invalid or unexpected token.

https://pastebin.com/EZ0Twpan - heres a pastebin with the raw command. Idk how to do it without the emojis on here

Hey @Sharp Shrimp!

I think it's because the second array uses wrong quotation marks, here's a fix:

$(eval w=[`with a cactus.`,`with a frying pan.`,`with a brick.`,`with common sense.`,`with heavy sarcasm.`,`with a raw fish.`]; a=[`It was super effective!`,`It was not very effective.`,`It had no effect.`]; `$(user) has slapped $(touser) ${w[Math.floor(Math.random()*w.length)]} ${a[Math.floor(Math.random()*a.length)]}`)

And to post code lines like this ↑ add four spaces before the line, if you want to post more structured code put it between two set of three backticks: `

Polar Cat said:
```
$(eval w=[with a cactus.,with a frying pan.,with a brick.,with common sense.,with heavy sarcasm.,with a raw fish.]; a=[It was super effective!,It was not very effective.,It had no effect.]; $(user) has slapped $(touser) ${w[Math.floor(Math.random()*w.length)]} ${a[Math.floor(Math.random()*a.length)]})
```

Thanks a bunch! Gonna go try it now!

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

Ask on Discord