Hi. i’m currently attempting to make a discord bot using Glitch, and I have in my local index.js a random image generator that pulls from a host of files in a folder in my local folder. Since I’m working through Glitch now, I tried to convert my code into the Glitch system but it keeps coming up with errors. Does anyone have a simple code I can just input to use with the assets that I’ve also added into Glitch so I can make this run?
Thanks!
You can upload your images as an asset then you can use Math.random() function.
Here’s an example:
let imageUrls = ["glitch", "assets", "url"] // your assets urls goes here
let randomImage = imageUrls[Math.floor(Math.random() * imageUrls.length)];
console.log(randomImage) // that shows a random string from "imageUrls "
see ya!
it’s still coming up with an error? I input into the code and it’s still not…working…
hey its possible your images are in the glitch assets folder. if they are you can get a link to them there and use it, and if you really want them in your project just go in the console and use wget url