Random 8=====D Sizes Command

Asked Aug 30, 2022·2 replies·Last activity 3 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.

Looking for help, and not sure why it won't work. - new to writing commands and javascript, but looking for random numbers of "=" within' the 8=D. I wrote it in another language, but am having troubles.

Here is my code:
!repeat $(eval let bSck = "8";
let length = Math.floor() * 30;
for(var i=0; i < length; i++)
{
ballSck += '=';
})

But when I test this so far, it doesn't give me what I need. What am I doing wrong?

2 replies

Hey @Easy Rabbit!

JavaScript has a .repeat() method to avoid the cumbersome for loop:

!addcom !commandName $(eval `8${'='.repeat(Math.floor(Math.random() * 30) + 1)}D`)

Your issue is that for length you were multiplying Math.floor() with 30, Math.floor() rounds down numbers, it doesn't represent any number by itself, what you're looking for is a random number generator.

Thank you so much, and it's very similar to how it was written using stream elements commands. I don't know why I was struggling, but I think I just need to study nightbot a little more, and javascript. But to be honest with you, I started out relatively simple, but a friend told me I needed a for loop, and I got all lost with it. Thanks again.

I will be using this resource again in the future.