Javascript Discord.MessageAttachment()未附加到嵌入

Javascript Discord.MessageAttachment()未附加到嵌入,javascript,discord,discord.js,Javascript,Discord,Discord.js,因此,我尝试将图像附加到discord嵌入(最好作为缩略图)。图像本地存储在我的硬盘上。我目前正在这样做: attachment=wait new discord.MessageAttachment('serverFavicon.png','favicon.png'); 嵌入.set缩略图(附件); 这将返回此错误,并且不发送嵌入: (node:60598) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body

因此,我尝试将图像附加到discord嵌入(最好作为缩略图)。图像本地存储在我的硬盘上。我目前正在这样做:

attachment=wait new discord.MessageAttachment('serverFavicon.png','favicon.png');
嵌入.set缩略图(附件);
这将返回此错误,并且不发送嵌入:

(node:60598) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
embed.thumbnail.url: Could not interpret "{'attachment': 'serverFavicon.png', 'name': 'favicon.png'}" as string.
    at RequestHandler.execute (/Users/manders/Desktop/Bots/Minecraft Server Discord Bot/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async RequestHandler.push (/Users/manders/Desktop/Bots/Minecraft Server Discord Bot/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:60598) 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:60598) [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.
奇怪的是如果我这样做了

message.channel.send('Image',附件);
它将成功发送图像

所以我想知道为什么它不会附加到嵌入,但它可以发送到频道。

只接受字符串(图像的URL),而不是
消息附件

在您的示例中,您可以简单地使用图像的URL:

embed.set缩略图('serverFavicon.png');
如果要重命名图像,可以在发送消息时附加
MessageAttachment
,并使用
attachment://image-name.png
对于缩略图URL:

//您也不需要在此处使用wait;构造函数不能是异步的
const attachment=new discord.MessageAttachment('serverFavicon.png','favicon.png');
embed.set缩略图('attachment://favicon.png');
// ...
message.channel.send({embed,files:[附件]});
有关在嵌入中使用附件的更多信息,请参阅