我已经想了很久了。我不知道如何让机器人把图片附加到嵌入中。我正试图从我的电脑上传一张照片。
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;
2条答案
按热度按时间6yoyoihd1#
既然你想从本地磁盘上传你的图像,你需要告诉Discord嵌入正是如此。每个嵌入都有一个.attachFile()方法,您可以从本地磁盘上传文件,并直接在嵌入中使用以下语法:
attachment://fileName.extension
以avatar.png文件为例,您需要
如果需要一次上载多个文件,请使用.attachFiles()方法。
kokeuurv2#
在
discord.js
v14中,我们有一种新的发送附件的方式。我们现在有了AttachmentBuilder
,但代码更改应该很容易。只需从discord.js导入AttachmentBuilder
即可