Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda