Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

294
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda