Reputation: 15
I want my Discord bot to set role as the user input corresponding role args, e.g: !role btcm, !role nccm, etc.
I'm having a problem with the discord.js addRole() function as I can't see its documentation on discord.js.org.
The console show TypeError: member.addRole is not a function
module.exports = message => {
const member = message.member;
switch(message.content.split(" ")[1]){
case "btcm":
roleID = "THE ID No.1"
case "nccm":
roleID = "THE ID No.2"
case "guest":
roleID = "THE ID No.3"
let roleAtts = message.guild.roles.cache.get(roleID);
member.addRole(roleAtts);
channel.send("Successfully set a role");
}
}
Upvotes: 1
Views: 107
Reputation: 5174
Since discord.js v12, you need to use roles.add()
instead of addRole()
member.roles.add(roleAtts);
Upvotes: 2