I keep getting fh bind errors, I keep getting errors as I'm trying to assign roles on join with discord
client.on('guildMemberAdd', role => {
console.log('user' + role.username + ' joined the battle!');
var role = role.guild.roles.cache.find('name', 'member' )
role.addrole(role)
});
This is because you are using role.guild.roles.cache.find
incorrectly. According to the manual , this function works similar to Array.find
in JavaScript .
The method takes a function that is supposed to return true
for elements in the cache matching your search criteria, for example:
var role = role.guild.roles.cache.find(r => r.name === 'member');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.