DiscordJS Send Embed in DM



我正在对DM特定用户的命令进行嵌入,这是我项目中的帮助菜单。我成功地发送了正常的消息,但我不能得到如何发送嵌入在DM!,我读到它需要另一种嵌入方式。

module.exports = {
name: 'costietare',
description: "This is a help command.",
async execute(client, message, args, Discord) {


message.delete({timeout: 10});
let dUser =
message.guild.member(message.mentions.users.first()) ||
message.guild.members.get(args[0]);
if (!dUser) return message.channel.send("Can't find user!");
if (!message.member.hasPermission('ADMINISTRATOR'))
return message.reply("Insufficient Permissions!");

let embed = new Discord.MessageEmbed()
.setTitle('General Information')
.setColor('YELLOW')
.addFields(
{name: 'Developer', value: '[m1](https://steamcommunity.com/id/catshvh)', inline:false},
{name: '!commands', value: 'More Commands & Usage for the bot', inline:true},
{name: 'BUY/Support', value: "[Click here to buy](https://discord.gg/4Qt3238jCy)", inline:true},
)
.setTimestamp()


dUser.send(`Sunt tare, stiu`); << Here is the normal message that its perfectly fine and 
dUser.send(`${embed}`); << this reply with **[object Object]**
message.author.send(
`${message.author} You have sent your message to ${dUser}`
);    
}

}

假设你使用的是discord版本12或更低版本,使用这个来发送嵌入

const embed = new Discord.MessageEmbed().setDescription('test');
message.channel.send(embed);
// for users
dUser.send(embed); // 

如果你使用的是discord version 13

const embed = new Discord.MessageEmbed().setDescription('test');
message.channel.send({ embeds: [embed] });
//for users (dms)
dUser.send({ embeds: [embed] });

它发送对象范围,也就是[object object]因为你把嵌入对象包装在模板字面量${}中,只要把嵌入对象作为一个普通参数传递进去,它就应该工作了