首页 > 解决方案 > 回复消息时无法在消息中添加图像

问题描述

我正在尝试将图像附加到作为重播的消息上。

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

但仅发送作为字符串的“概述”,没有“poster_path”图像。

为什么会这样,我该如何解决?

我已经检查并且 JSON 数据是有效的。

标签: javascriptimagediscord.jsmessageimageurl

解决方案


为了使您的代码更清晰并避免内存过载,您可以调用一次


   // 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});



尝试在控制台中查看 firstResult 以确认响应。


推荐阅读