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

176
Vistas
Why does the random generator not work? discord.js
const { Client, Attachment, Message, MessageEmbed } = require("discord.js");

const items = [ "Test1", "Test2", "Test3"

]

const item = items[Math.floor(Math.random() * items.length)];

module.exports = {
    name: "test",
    description: "",

    /**
     * @param {Message} message 
     * @param {Client} client 
     */
    
    execute(message, args, client) {

        const mess = "You win:"

        var embed = new MessageEmbed();
        if (item == "Test1") {
            embed.setDescription(mess + " Test1")
        } else if (item == "Test2") {
            embed.setDescription(mess + " Test2")
        } else if (item == "Test3") {
            embed.setDescription(mess + " Test3")
        }
        embed.setTitle("tEsT")
        embed.setColor('#bd2ecc')

        const embed1 = new MessageEmbed()
        .setTitle("Searching...")
        .setColor("bd2ecc")

        message.channel.send({embeds: [embed1]}).then((msg) => {
            setTimeout(function() {
                msg.edit({content: "\n", embeds: [embed]})
            }, 3000)
        });

    }
};

I'm trying to get the embed to respond to one of the contents of "items", unfortunately nothing is generated randomly, and I'm wondering how to fix this, I have about a guess because only test3 is always displayed, but no idea how to fix it

I hope someone can help me

about 4 years ago · Juan Pablo Isaza
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