我想让我的机器人在我的朋友第一次加入我的服务器时自动扮演角色:我已经尝试过这个我的 VPS 节点版本:12.19.0v:?
I wanna make my bot give automatically role when my friends join for first time to my server: I have tried this one my VPS node version: 12.19.0v:?
client.on('guildMemberAdd', member => {
console.log('User @' + member.user.tag + ' has joined the server!');
var role = member.guild.roles.cache.find(role => role.name == "Newbie")
let user = member.user
user.roles.add(role);
});
但没有任何效果!请帮帮我
but nothing is working ! help me pls
Discord 现在正在强制执行特权意图.GUILD_MEMBERS
Intent 是接收 guildMemberAdd
和 guildMemberUpdate
等事件所必需的.
Discord is now enforcing privileged intents. The GUILD_MEMBERS
intent is required to receive events such as guildMemberAdd
and guildMemberUpdate
.
要了解意图的工作原理以及如何使用它们,请查看 discord.js 的详细指南一个>.
To learn how intents work and how to use them, check out discord.js' detailed guide.
另外,如评论中所述,您需要使用 message.member
而不是 message.user
Also, as stated in the comments, you need to use message.member
instead of message.user
这篇关于为 discord.js v12 创建一个自动角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!