I wan’t my bot to give a certain role to people when they join the server. But I get some weird error I don’t really understand.
This is the code
const { GuildMember, MessageEmbed } = require("discord.js");
module.exports = {
name: "guildMemberAdd",
/**
* @param {GuildMember} member
*/
async execute(member){
let role = member.guild.roles.cache.some(role => role.name === 'Member')
member.roles.add(role)
member.guild.channels.cache.get(process.env.WELCOME_MESSAGE_CHANNEL_ID).send({
embeds: [
new MessageEmbed()
.setTitle("Welcome! :smiley:")
.setDescription(`${member.toString()} has joined the server!n
Thanks for joining. Head over to <#${process.env.RULE_CHANNEL_ID}> and verify yourself in <#${process.env.VERIFY_CHANNEL_ID}> to get access to all other channels.`)
.setThumbnail(member.user.displayAvatarURL())
.setColor("GREEN")
]
})
}
}
And after someone joins I get this error message
TypeError [INVALID_TYPE]: Supplied roles is not a Role, Snowflake or Array or Collection of Roles or Snowflakes.