javascriptimagediscord.jsmessageimageurl

Adding image to a message does not work when replying to a message


I am trying to get an image attached to a message which is a replay.

msg.reply(JSON.parse(data).results[0].overview, { file : JSON.parse(data).results[0].poster_path});

but only the "overview" which is a string get sent, without the "poster_path" image.

Why is that and how can I fix it?

I have checked and the JSON data is valid.


Solution

  • To make your code clearer and avoid memory overload, you can call this once

    
       // get first value
       var firstResult = JSON.parse(data).results[0];
    
       // confirm the result
       console.log(firstResult);
    
       // action
       msg.reply(firstResult.overview, { file : firstResult.poster_path});
    
    
    
    

    try view firstResult in the console to confirm the response.