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

175
Views
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
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!