我试图让我的机器人将用户发送到特定频道的确切消息发送给特定频道(包含嵌入内容),但机器人却发送文本,但不发送附件
这是代码
bot.on('message', message => {
if (message.author.bot) return;
if(message.channel.id == "771695635598278677") {
message.delete()
const user = message.mentions.users.first() || message.author;
let messageAttachment = message.attachments.size > 0 ? message.attachments.array()[0].url : null
const dark = new Discord.MessageEmbed()
.setColor('#000000')
.setDescription(message.content)
.setAuthor("Dark Chat", `${message.author.displayAvatarURL()}`)
.setImage((messageAttachment)) //message.attachments.first() || {}).url
.setFooter('Dark Chat', 'https://cdn.discordapp.com/attachments/564032243836780558/771614643159433226/Anonymous_emblem.svg.png')
if(isNaN(message.content)) {
message.channel.send(dark)
}
}
});
答案 0 :(得分:0)
https://discord.js.org/#/docs/main/stable/class/MessageEmbed?scrollTo=setImage
.setImage(message.attachments.array().length == 0 ? null:message.attachments.first().url)