This might be innapropriate, but I am making a discord bot, and in the process I wanted to make a "gif" command. I had chosen the Giphy api as it seemed to be the most simple one out there. But everytime I ask the bot to fetch a trending gif, it gives me the same gifs. (Example attached) Here you can see he bot sending the same gif 2 times
Here is the code needed for this command:
if (message.content.startsWith(`${prefix}gif`)) { giphy.trending('gifs', {limit:100}) .then((response) => { var totalResponses = response.data.length; var responseIndex = Math.floor((Math.random() * 10) + 1) % totalResponses; var responseFinal = response.data[responseIndex]; message.channel.send("Here is a gif for you!\n", { files: [responseFinal.images.fixed_height.url] }).catch(() => { message.channel.send('There was an API error, please try later.') }) }) } })``` Any answers are appreciated. https://stackoverflow.com/questions/65622713/giphy-api-always-gives-the-same-gifs-discord-js January 08, 2021 at 10:41AM
没有评论:
发表评论