Ask coding questions

← Back to all posts
How to make a variation code?
Stanhil (0)

I want my bot to be able to randomly choose 10 animated gifs to present, but I've been trying to make this code for a long time but I can't.
The bot is for a server on Discord.
I only have this code below, where it shows only one gif.

Comments
hotnewtop
EpicGamer007 (1615)

you can make a list of links like const links = ["link1", "link2", ".."] then in your code, you can do .setImage(links[Math.floor(Math.random() * links.length); ]).

At the moment, you make the setImage use the image https://2img.net/h/25.media.tumblr.com/tumblr_m5kz58xyAo1rxsvxdo1_500.gif which means that image will be displayed every time.

Stanhil (0)

@EpicGamer007 Thanks, it worked perfectly.

EpicGamer007 (1615)

@Stanhil np, if you wouldn't mind, can you click the green check mark next to the answer? Thanks.