是否可以将本地文件用作DiscordJs嵌入消息的缩略图?
"thumbnail": {
"url": "../img/025.png"
},
这似乎不起作用.
(node:34721) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1):
DiscordAPIError: Invalid Form Body
embed.thumbnail.url: Not a well formed 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"
}
};
通过以下方式将图像附加到消息中:
message.channel.send({
embed,
files: [{
attachment:'img/image.png',
name:'image.png'
}]
});