NightDev Community Forums

Custom 8ball command

I’m wondering if it’s possible to make a custom 8ball command to return only 2 answers, but have one result appear 511 times and the other only once.
So when someone uses the command they would have a 1 in 512 chance of returning result 2 and a 511 in 512 chance of result 1.

Hey @mynameismaggzy!

Here’s the code you’re looking for:

$(eval r=[Math.floor(Math.random()*512)]+1; r>511?`RARE_MESSAGE`:`FREQUENT_MESSAGE`;)

Replace FREQUENT_MESSAGE with the one you want to happen 511 times out of 512, and RARE_MESSAGE with the one you want to happen only 1 time out of 512.

Edit: fixed the command, it should work as intended now, silly me wanting to go too fast in my code to save unnecessary space.

1 Like

thank you so much
I noticed when i added the command the RARE_MESSAGE was showing up 511/512 and FREQUENT_MESSAGE was actually the 1/512

Oh, was it? So weird, this shouldn’t have been the case if you copied/pasted it, because I tested it, and also because of how it’s written. But I’m glad you got it working!

Yeah I copied and pasted but it’s okay I just changed the messages around, also I’m not sure if we are that lucky but after using it a fair few times maybe around 30-50 times we had the 1 in 512 chance come up 4 times lol I will test again today.

Hmm, okay, that’s odd, this shouldn’t be happening… Here, I wrote it again using basic coding, this way I’m sure it’ll work reliably.

$(eval r=[Math.floor(Math.random()*512)]+1; if(r==512){`RARE_MESSAGE`}else{`FREQUENT_MESSAGE`})

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