【问题标题】:(node:26) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty(节点:26)UnhandledPromiseRejectionWarning:RangeError [EMBED_FIELD_VALUE]:MessageEmbed 字段值可能不为空
【发布时间】:2021-08-28 09:27:18
【问题描述】:

我有一个代码,我想让机器人发送随机图像。但是频道中的图片没有加载

我得到这个错误:

(node:26) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed 字段值不能为空。

at Function.normalizeField (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:432:23)
at /home/container/node_modules/discord.js/src/structures/MessageEmbed.js:452:14
at Array.map (<anonymous>)
at Function.normalizeFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:451:8)
at MessageEmbed.addFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:266:42)
at MessageEmbed.addField (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:257:17)
at Client.<anonymous> (/home/container/index.js:117:2)
at processTicksAndRejections (internal/process/task_queues.js:95:5)

代码:

var images = ["https://i.imgur.com/7mUR1Pl.jpg", "https://imgur.com/eH9gPXu", "https://imgur.com/60YLPki" ];
var image = Math.floor(Math.random() * images.length);

if (message.content.toLowerCase() === "!gtafoto") {    
    let embed = new Discord.MessageEmbed()
      .setTitle('Hier is je GTA foto!')
      .setColor("#f1c40f")
      .setFooter('Mogelijk gemaakt door Gijs#0001')
      .setImage(String([images[image]]))

    message.channel.send(embed);
}

【问题讨论】:

    标签: node.js discord.js


    【解决方案1】:

    我认为问题在于图像的唯一链接是第一个(以.png结尾),另外两个是图像页面的链接,不能显示为图像本身。您只需在每个还没有链接的链接末尾添加.png

    【讨论】:

      猜你喜欢
      • 2021-10-09
      • 2021-07-16
      • 2020-12-10
      • 2021-12-04
      • 2020-09-24
      • 2020-11-16
      • 2021-09-04
      • 2021-08-05
      • 2021-08-24
      相关资源
      最近更新 更多