discord.js 随机图片显示不正确

discord.js random images displaying incorrectly

我想从 url 中抓取随机图像,但是当我在 discord 中调用命令时,它一遍又一遍地提供相同的图像。但是当我重新启动机器人并再次 运行 时,图像发生了变化,但仍然一遍又一遍地播放不同的图像,没有任何变化?如果有任何帮助,我将不胜感激

else if (message.content.startsWith(prefix + "randimg") && message.author != client.user) {
  message.channel.send({embed: {
      color: 0x0000FF,
      author: {
          name: client.user.username,
          icon_url: client.user.avatarURL
      },
      title: "Random Image Test",
      image: {
          url: "https://source.unsplash.com/random",
      },
      description: "Random Image Generation"
  },
  currentTimestamp: new Date(),
  footer: {
    icon_url: client.user.avatarURL,
    text: "2018 @ Canarado"
  }
})

我想也许这是因为它一遍又一遍地从同一个随机 img url 中抓取它们,但我不知道如何改变它。谢谢你,我希望有人能够提供帮助。

缓存是否可能是根本原因?您尝试向 url 添加一个随机参数吗?

image: {
      url: "https://source.unsplash.com/random" + "?rnd=" + Math.random(),
  },

所以经过仔细研究,问题确实是缓存,但是另一个可用的答案(虽然很好并且帮助我思考)没有正确格式化link。我发现这是随机 unsplash link.

的正确格式
          image: {
          url: "https://source.unsplash.com/random?sig=" + Math.random(),
      },