delete role Discord.js code example
Example 1: how to give roles discord.js
let role = message.guild.roles.find(r => r.name === "Role Name");
let member = message.mentions.members.first();
member.roles.add(role)
Example 2: discord.js find role by name
let role = message.guild.roles.cache.find(role => role.name === "Rolename");
Example 3: discord.js remove every role a user has
case "suspend":
if (message.member.hasPermission('MANAGE_ROLES')) {
let rMember = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if (!rMember) return message.reply("That user does not exist.");
let gRole = message.guild.roles.find('name', 'SUSPENDED');
rMember.removeRoles(rMember.roles).then(console.log).catch(console.error);
rMember.addRole(gRole.id);
message.channel.send("User was suspended.");
try {
await rMember.send("You have been suspended.");
} catch (e) {
message.channel.send("We tried to DM the user to let them know, but their DM's are locked.");
}
} else {
message.channel.send("You do not have permission to use this command.");
}
break;