Hed*_*dva 4 javascript image discord
是否可以使用本地文件作为带有 DiscordJs 的嵌入消息的缩略图?
"thumbnail": {
  "url": "../img/025.png"
},
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用。
(node:34721) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1):  
DiscordAPIError: Invalid Form Body 
embed.thumbnail.url: Not a well formed URL.
Run Code Online (Sandbox Code Playgroud)
然而,普通的 URL 确实有效。
我已经找到了答案。链接到文件的正确 url 对我来说不是一个选项,因为生成了一些图像。
您可以将图像附加到消息中,并将此附件用作缩略图。最基本的例子:
const embed = {
  "title": "A Title" ,
  "color": 0xF96221,
  "thumbnail": {
    "url": "attachment://image.png"
  },
  "fields": [
    {
      "name": "Field 1:",
      "value": "One",
      "inline": false
    },
    {
      "name": "Field 2:",
      "value": "Two",
      "inline": true,
    },
    {
      "name":"Field 3:",
      "value":"Three",
      "inline": true
    },
  ],
  "footer": {
    "text":"Footer text"
  }
};
Run Code Online (Sandbox Code Playgroud)
将图像附加到消息中:
message.channel.send({
  embed,
  files: [{
    attachment:'img/image.png',
    name:'image.png'
  }]
});
Run Code Online (Sandbox Code Playgroud)
        其他方法希望对你有帮助
const attachment = new Discord.MessageAttachment('fileRoute', 'nameOfYourPicture');
const embed = new Discord.MessageEmbed()
  .setTitle('Title')
  .setColor('#8fda81')
  .addField('Message Send', messageToSend)
  .attachFiles(attachment)
  .setThumbnail('attachment://nameOfYourPicture');
message.channel.send(embed);
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           12162 次  |  
        
|   最近记录:  |