He estado jugando con el raspador de imágenes (discord.js v13). Me encantaría hacerlo así cada vez que hago, por ejemplo ?image car , envía una imagen diferente del auto.
Este es mi código rn, es simplemente raspador simple básico
const google = new Scraper({ puppeteer: { headless: true, }, }); module.exports = { name: 'image', description: 'Send picture (possibly automatically maybe)', async execute( kaoru, message, args, Discord){ const image_query = args.join(' '); if(!image_query) return message.channel.send('> **Please enter name of the image!**'); const image_results = await google.scrape(image_query, 50); message.channel.send(image_results[0].url) } }``` Any ideas? I tried to google help, but didnt find anything. Also i think it has something to do with this part: ```message.channel.send(image_results[0].url)``` Because if i change [0] to [2] for example, it changes that pic. But it would be cool if it would send pics between 0-100Puede usar un aleatorizador para establecer el valor en image_results. Como esto:
image_results[Math.floor(Math.random() * 50)].urlEso debería darte un número entero aleatorio entre 0 y 49 (el índice js comienza en 0).