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

219
Vistas
Array variable inside .setImage() doesn't work. discord.js

I am trying to get my bot to send and embed and I want the gif to change each time, but for some reason when I put the array variable inside the .setImage() it doesn't work. The message is sent, but its just missing a picture. Here is my code.

var string1 = message.content.substring(6);
        let channel = message.channel;
        var Gifs = ['https://media.giphy.com/media/yUzMZZWrU6aZy/giphy.gif', "https://th.bing.com/th/id/R.e2cf7c01031a331ccef83051a973ea9e?rik=9NSxT6EyIBiNfw&riu=http%3a%2f%2fgifimage.net%2fwp-content%2fuploads%2f2017%2f07%2fanime-slap-gif-13.gif&ehk=Z1bcjra0ue2IWQAqeic6ZrIkMFS6Hxcvk%2boKlN5TPF4%3d&risl=&pid=ImgRaw&r=0", "https://media1.tenor.com/images/f619012e2ec268d73ecfb89af5a8fb51/tenor.gif?itemid=8562186", "https://media.giphy.com/media/L7iHfUrBk3cqY/giphy.gif", "https://gifimage.net/wp-content/uploads/2017/07/anime-slap-gif-12.gif"];
        var anim = Math.floor(Math.random() * 5);
        var anims = anim[Gifs];
        const exampleEmbed = new Discord.MessageEmbed()
          .setColor('#04785f')
          .setTitle('Instant Replay:')
          .setImage(anims)
          .setTimestamp()
        console.log(string1)
        message.channel.send('You slapped: ' + string1);
        channel.send(exampleEmbed);

Here is what it returns

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

var string1 = message.content.substring(6);
        let channel = message.channel;
        var Gifs = [
'https://media.giphy.com/media/yUzMZZWrU6aZy/giphy.gif',
"https://th.bing.com/th/id/R.e2cf7c01031a331ccef83051a973ea9e?rik=9NSxT6EyIBiNfw&riu=http%3a%2f%2fgifimage.net%2fwp-content%2fuploads%2f2017%2f07%2fanime-slap-gif-13.gif&ehk=Z1bcjra0ue2IWQAqeic6ZrIkMFS6Hxcvk%2boKlN5TPF4%3d&risl=&pid=ImgRaw&r=0",

//"https://media1.tenor.com/images/f619012e2ec268d73ecfb89af5a8fb51/tenor.gif?itemid=8562186", 
// invalid link

"https://media.giphy.com/media/L7iHfUrBk3cqY/giphy.gif", 

// "https://gifimage.net/wp-content/uploads/2017/07/anime-slap-gif-12.gif"
// invalid link
];
        const anim = Gifs[Math.floor(Math.random() * Gifs.length)];

        const exampleEmbed = new Discord.MessageEmbed()
          .setColor('#04785f')
          .setTitle('Instant Replay:')
          .setImage(anim)
          .setTimestamp()

        console.log(string1)

// if using discord v12
        channel.send(`You slapped: ${string1}`);
        channel.send(exampleEmbed);

// if using discord v13
        channel.send({
            content: `You slapped: ${string1}`,
            embeds: [exampleEmbed]
        })
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