Javascript Discord.js嵌入图像不工作。(无法解释";{';url';:';https://cdn.nekos.life/boobs/boobs105.gif'“}”作为字符串。)

Javascript Discord.js嵌入图像不工作。(无法解释";{';url';:';https://cdn.nekos.life/boobs/boobs105.gif'“}”作为字符串。),javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,My command.js 基于其他一些机器人,如Harutohroki机器人,Github上的开源和Nekos.life文档 错误: > node . (node:25052) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time Logged in and connected as Bot#1234

My command.js

基于其他一些机器人,如Harutohroki机器人,Github上的开源和Nekos.life文档

错误:


    > node .
    (node:25052) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time
    Logged in and connected as Bot#1234
    { url: 'https://cdn.nekos.life/boobs/boobs105.gif' }
    (node:25052) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
    embed.image.url: Could not interpret "{'url': 'https://cdn.nekos.life/boobs/boobs105.gif'}" as string.
        at RequestHandler.execute (C:\Users\User\Documents\GitHub\Bot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    (node:25052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)(node:25052) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

我的问题

如何解决这个问题?(我试了一天,但没有成功,需要尽快帮助)

我修复了它:

const Discord = require('discord.js');
const client = require('nekos.life');
const neko = new client();

module.exports.run = async (bot, message, args) => {
  if (message.channel.nsfw === true) {
      link = await neko.nsfw.boobs()
      const embed = new Discord.MessageEmbed()
          .setAuthor(`Some neko boobs`)
          .setColor('#00FFF3')
          .setImage(link.url)
          .setFooter(`Bot by`);
          message.channel.send(embed);
    } 
  else {
    message.channel.send("This isn't NSFW channel!")
  }
};

module.exports.config = {
    name: "boobs",
    description: "",
    usage: "*boobs",
    accessableby: "Members",
    aliases: []
}

它看起来像是
neko.nsfw.boobs()
返回一个字符串,而不是
字符串。请尝试以下方法:

const{url}=wait neko.nsfw.boobs();//只获取URL,而不是整个对象
const embed=new Discord.MessageEmbed()
.setAuthor(`Some neko boobs`)
.setColor(“#00FFF3”)
.setImage(link.url)
.setFooter(`Bot by`);
message.channel.send(嵌入);

下面是一个代码片段示例:

const-link={
网址:'https://cdn.nekos.life/boobs/boobs105.gif'
};
console.log(链接);//这不会给出链接。它将给出整个对象
/*使用对象分解,您可以使用括号捕获一个对象
数组的属性。在本例中,url。
对象分解-https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
*/
常数{
网址
}=链接;
console.log(url);//这将只提供链接

console.log(link.url);//另一种只给出链接的方法
请在你的答案中加入一些解释,这样每个人都能理解你到底改变了什么。
const Discord = require('discord.js');
const client = require('nekos.life');
const neko = new client();

module.exports.run = async (bot, message, args) => {
  if (message.channel.nsfw === true) {
      link = await neko.nsfw.boobs()
      const embed = new Discord.MessageEmbed()
          .setAuthor(`Some neko boobs`)
          .setColor('#00FFF3')
          .setImage(link.url)
          .setFooter(`Bot by`);
          message.channel.send(embed);
    } 
  else {
    message.channel.send("This isn't NSFW channel!")
  }
};

module.exports.config = {
    name: "boobs",
    description: "",
    usage: "*boobs",
    accessableby: "Members",
    aliases: []
}