Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
How can i make Discord.js Image scraper to send new image everytime

I have been messing around with image scraper (discord.js v13). I would love to make it so everytime i do for example ?image car it sends different picture of car.

This is my code rn, its just basic plain scraper


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-100 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use a randomizer to set the value in image_results. Like this:

image_results[Math.floor(Math.random() * 50)].url

That should give you a random integer between 0 and 49 (js index starts at 0).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!