我正在为我的服务器制作一个机器人,我希望它通过一个带有主题的命令向所有对指南消息中的特定主题做出反应的用户发送 DM。
E.G. !通知主题
我的代码目前如下所示:
client.guilds.cache.forEach(guild => {
guild.members.cache.forEach(member => {
member.send(new Discord.MessageEmbed()
.setColor("#FF0000")
.addField(" ", message.author)
.addField("Subject", content)
.setTimestamp()
)
})
})
await message.channel.send(`${message.author} the message was successfully sent!`);
答案 0 :(得分:0)
事情是这样的:
在您的 guild.members.cache.forEach()
中,您指的是 GuildMember
,然后您使用 .send()
方法。问题是 GuildMember 没有 send 方法,这意味着您必须使用 User
。
client.guilds.cache.forEach(guild => {
guild.members.cache.forEach(member => {
member.user.send(new Discord.MessageEmbed() // This is where the issue was located
.setColor("#FF0000")
.addField(" ", message.author)
.addField("Subject", content)
.setTimestamp()
)
})
})
await message.channel.send(`${message.author} the message was successfully sent!`);