I'm trying to write a Discord bot that when It gets the address replies the products. And so it doesn't reply only the first product I wrote a for loop that loops through all products and replies in a new message the Product name, Description, and capacity. But nothing is happening on the server. No messages no anything. This is the part I from my code that is supposed to reply and in the meantime convert the address into latitude and longitude get the products and reply them
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']);
}
};
});
});
For Discord I use Discord.JS but there isn't a tag yet for that service
If you would like to know the reason it's failing to send the message I would suggest catching the promis rejection from bot.reply()
Something like
bot.reply().catch((error)=>{console.log(error)};
Then check your console for the reason it's failing to send.