是否可以将本地文件用作带有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.
普通网址可以正常运作。
答案 0 :(得分:4)
我已经找到了答案。 链接到文件的正确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'
}]
});
答案 1 :(得分:2)
其他方法,希望对您有帮助
const attachment = new Discord.MessageAttachment('fileRoute', 'nameOfYourPicture');
const embed = new Discord.MessageEmbed()
.setTitle('Nueva Tarea')
.setColor('#8fda81')
.addField('Mensaje Enviado', textoEnviar)
.attachFiles(attachment)
.setThumbnail('attachment://nameOfYourPicture');
message.channel.send(embed);