Can anyone assist me with a Discord bot command issue? I'm trying to make a command that sends a random Kirby gif using the Giphy API, but it keeps sending multiple gifs instead of just one. Here is the code snippet:
client.on('message', message => {
if (message.content === 'k!gif')
giphy.search('gifs', {"q": "kirby"})
.then((response) => {
var totalResponses = response.data.length
var responseIndex = Math.floor((Math.random() * 10) + 1) % totalResponses;
var responseFinal = response.data[responseIndex]
message.channel.send("We stan kirby gifs", {
files: [responseFinal.images.fixed_height.url]
})
}).catch(() => {
message.channel.send('Kirby has run into a roadblock and was unable to complete his task.');
})
})
Your help is greatly appreciated!