Linking a solution with example since this bug came up again!
const giphy = require("giphy-api")();
client.on('message', async (message) => {
//gifs
if(message.content.includes("!gif")){
const args = message.content.slice().trim().split(/ +/g);
const command = args.shift().toLowerCase();
let converts = args.join(" ");
if(converts ==""){converts = "random"}
message.delete(1)
giphy.search({q: converts,rating: 'g'}, function (err, response) {
if(response.data.length == 0){
let embed2 = new Discord.RichEmbed()
.setColor(0x00ae86)
.setDescription(`🎬 Sorry I Can't find a gif related with your words.`)
message.channel.send({embed:embed2})
return;
}
var totalResponses = response.data.length;
var responseIndex = Math.floor((Math.random() * 10) + 1) % totalResponses;
let embed = new Discord.RichEmbed()
.setColor(0x00ae86)
.setDescription(`🎬**Name:** "${response.data[responseIndex].title}".`)
.setImage(response.data[responseIndex].images.original.url)
message.channel.send({embed:embed}).then(embedMessage => {
embedMessage.react("👍")
embedMessage.react("👎")
.catch(() => console.error("One of the emojis failed to react."));
embedMessage.delete(15000)
})
})
}
})
TypeError: Cannot read property ‘length’ of undefined
@NathanCombrun, the latest version (v2.0.3) of the package is actually deprecated (Glitch prompts you to upgrade to the latest version), I suggest you downgrade the package to v1.0.6.