问题描述
当我的朋友第一次加入我的服务器时,我想让我的机器人自动扮演角色:我已经尝试过这个我的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
意图来接收诸如 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制作autorole的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!