尝试使用 msg.mentions.users.first 执行 dm 命令,但它不起作用


if(msg.content.startsWith("&%walcome")){
const mentionid = bot.users.cache.get(`${msg.mentions.users.first().id}`)
const up = new Discord.MessageEmbed()
.setColor('#C8CAF9')
.setTitle('Sup')
.setThumbnail(`${msg.mentions.users.first().displayAvatarURL()}`)
.setDescription(`Sup **${msg.mentions.user.first().tag}**, be welcome to MFPA Official Discord Community. If you joined withouht knowing wth is this server, I will explain: this is the official server of the series with the same new, that is available on youtube (https://www.youtube.com/channel/UCWZRrkidNF5Se8fkgGzoxgg)`)
.addFields(
{name: 'Fun in server', value: 'That is right, dear new member, you can actually have fun in this channel! We have some custom emojis, events, chat (sometimes is dead but eh-). But!, first of all, do not forget to go to #verify (823564914605686844) to get access to the server'},
{name: 'Specific Announcements', value: 'You can receive specific announcements (Faded Pics, Betro Ideas and Dani Sounds) if you are interested in the whole production of the series'},
{name: 'If you need help, just dm a staff member', value: 'Thats right, if you need help, you can contact one of the Staff Team member, they will reply when available'}
)
.setFooter(`Sent by ${msg.author.tag}, bot made by dani bear#3606`, `${msg.author.displayAvatarURL()}`)
mentionid.send(up)
}
})

所以,这个代码不起作用,我不知道为什么。错误是Cannot read property 'first' of undefined,但我已经用过了,它起作用了-

如果你能帮忙,我将不胜感激!

您在.setDescription('Sup **${msg.mentions.user.first().tag...)}'中有一个拼写错误。它的msg.mentions.users.first()(在"users"中漏掉了一个"s"(。此外,如果您要一次又一次地使用提到的User对象,请将其存储在一个变量中,然后访问该变量的属性。

最新更新