【发布时间】:2016-09-19 06:28:34
【问题描述】:
我正在尝试编写一个 Discord 机器人,当它获得地址时会回复产品。因此它不仅仅回复第一个产品,我编写了一个循环遍历所有产品并在新消息中回复产品名称、描述和容量的 for 循环。但是服务器上什么也没有发生。没有消息什么都没有。这是我的代码中应该回复的部分,同时将地址转换为纬度和经度获取产品并回复它们
geocoder.geocode(address, function(err, res) {
console.log(res);
var latitude = res[0]["latitude"]
var longitude = res[0]["longitude"]
uber.products.getAllForLocation(latitude,longitude, function (err, res) {
if (err){
console.error(err);
bot.reply(message,err);
}
else {
console.log(res)
for (var i = 0; i < res.length; i++) {
bot.reply(message, i + "." + res['products'][i][' display_name'] + " " + res['products'][i]['description'] + " " + "Capacity: " + " " + res['products'][i]['capacity']);
}
};
});
});
对于 Discord,我使用 Discord.JS,但该服务还没有标签
【问题讨论】:
-
它将什么记录到您的控制台?您所在的位置有可用的服务吗?
-
它以 JSON 格式打印该地址可用的产品列表,如果有错误,它会输出并发送它
-
听起来问题与 Discord.JS 库有关
标签: node.js geocoding uber-api