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

177
Visualizações
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 à 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