Math.min eval command has stopped functioning

Asked Feb 21, 2025·2 replies·Last activity 1 year 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 had this command running on two channels with no problems maybe a year or two ago and have checked back recently to see this doesn't function anymore.

scans chat for power levels, $(touser) spikes the reading with a power level of $(eval [Math.min(Math.floor((Math.random() * 9001) + 1), Math.floor((Math.random() * 9001) + 1), Math.floor((Math.random() * 9001) + 1), Math.floor((Math.random() * 9001) + 1))])

The response doesn't give any number or even a js error message at the end
I don't know if this function is taking too long to run or if something else is blocking it now.
I simply want a weighted random number generator so, is there an alternative way to do this?

2 replies

The problem is the [brackets], you are generating an array. Try:

scans chat for power levels, $(touser) spikes the reading with a power level of $(eval Math.min(Math.floor(Math.random()*9001+1), Math.floor(Math.random()*9001+1), Math.floor(Math.random()*9001+1), Math.floor(Math.random()*9001+1)))