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

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

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 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