我已经试着弄清楚这个问题有一段时间了。我想不出如何让机器人将图像附加到嵌入式上。我正在尝试从我的电脑上传一张照片。
const commando = require('discord.js-commando');
const discord = require('discord.js')
class HoundCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'hound',
group: 'simple',
memberName: 'hound',
description: 'Tells info about hound'
});
}
async run(message, args) {
var myInfo = new discord.RichEmbed()
.setTitle("Hound")
.addField("Name", "Hound")
.addField("Age", "12")
.addField("Description", "Im good at siege, I stream occasionally and ya")
.setColor("#020B0C")
message.channel.sendEmbed(myInfo);
}
}
module.exports = HoundCommand;发布于 2019-01-07 10:28:56
因为你想从你的本地磁盘上传你的图像,所以你需要准确地说出不一致嵌入。每个embed都有一个.attachFile()方法,你可以从本地磁盘上传一个文件,并通过以下语法直接在你的embed中使用它:attachment://fileName.extension
因此,以一个名为avatar.png的文件为例,您需要
var myInfo = new discord.RichEmbed()
.setTitle("Hound")
.addField("Name", "Hound")
.addField("Age", "12")
.addField("Description", "Im good at siege, I stream occasionally and ya")
.setColor("#020B0C")
.attachFile('./avatar.png')
.setImage('attachment://avatar.png');
message.channel.sendEmbed(myInfo);如果您需要一次上传多个文件,请使用.attachFiles()方法。
https://stackoverflow.com/questions/54067769
复制相似问题