我有一个机器人,它显示主题公园的等待时间,但是当被请求时,它会为每个游乐设施发送一条消息,并且我想知道是否可以在一条消息中发送所有游乐设施。这是代码:
message.channel.send('**NOTE:** 0min wait means the ride is **closed**.')
IoA.GetWaitTimes().then(function(rides) {
for(var i=0, ride; ride=rides[i++];) {
const embed = new Discord.RichEmbed()
.setTitle('Wait Times for IoA')
.setColor(0x00AE86)
.setThumbnail('https://images-na.ssl-images-amazon.com/images/I/41Dz-pJ5AtL.jpg')
.addField(ride.name, ride.waitTime + "min wait")
message.channel.send(embed);
}
}, console.error);
return
答案 0 :(得分:1)
您可以在阵列上增加等待时间,最后发送包含该阵列所有参数的唯一消息。
message.channel.send('**NOTE:** 0min wait means the ride is **closed**.')
IoA.GetWaitTimes().then(function(rides) {
let tosend = []
for(let i=0, ride; ride=rides[i++];) {
tosend.push(`**${ride.name}**\n ${ride.waitTime} min wait`)
}
message.channel.send("**__Wait time for IoA__**\n\n" + tosend.join('\n'))
}, console.error);
return