Multiple random evals?

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)]:wink: $(eval a=[“It was super effective!”,“It was not very effective.”,”It does not affect $(touser).”]; a[Math.floor(Math.random()*a.length)]:wink:

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

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 @Kenz 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 @wyntreblossom07!

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: ```

2 Likes

Thanks a bunch! Gonna go try it now!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.