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

292
Views
node.js - Is there a way to make a discord bot send random pictures pulled from a file? node.js

So I'm new to Coding and I wanted to make a discord bot, I have an idea of how to do it, but I can't figure out how to do what I want. I was wondering if there is a way to add a bunch of photos a file and have the discord bot be able to pull a a random picture out of it to send it? As well as maybe on that pulls like 5 random ones and sends them?

I have no idea what to do, and I haven't found anything to help with it.

Currently I'm doing one where I have to add every image ID on its own and make really long lines of code for every command.

Any ideas???

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Array.prototype.rand = function() {
  return this[Math.floor((Math.random()*this.length))];
}

console.log(["a","b","c"].rand())

(new edit since my previous answer didn't seem to sit right with some people)

about 4 years ago · Juan Pablo Isaza Report

0

You can use Math.random() to pick a random image out of an array of images.

const imageArray = [...];
const randomImage = imageArray[Math.floor(Math.random()*imageArray.length)];
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!