我正在尝试在我的 discord 机器人上执行此命令,它使用 giphy api 发送一个随机的 kirby gif。但是,我只希望它发送一个,但它发送多个。这是代码:
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.');
})
})
感谢您提前提供帮助!